@@ -429,17 +429,18 @@ struct netcode_socket_holder_t
429
429
struct netcode_socket_t ipv6 ;
430
430
};
431
431
432
- #define NETCODE_SOCKET_ERROR_NONE 0
433
- #define NETCODE_SOCKET_ERROR_CREATE_FAILED 1
434
- #define NETCODE_SOCKET_ERROR_SET_NON_BLOCKING_FAILED 2
435
- #define NETCODE_SOCKET_ERROR_SOCKOPT_IPV6_ONLY_FAILED 3
436
- #define NETCODE_SOCKET_ERROR_SOCKOPT_RCVBUF_FAILED 4
437
- #define NETCODE_SOCKET_ERROR_SOCKOPT_SNDBUF_FAILED 5
438
- #define NETCODE_SOCKET_ERROR_BIND_IPV4_FAILED 6
439
- #define NETCODE_SOCKET_ERROR_BIND_IPV6_FAILED 7
440
- #define NETCODE_SOCKET_ERROR_GET_SOCKNAME_IPV4_FAILED 8
441
- #define NETCODE_SOCKET_ERROR_GET_SOCKNAME_IPV6_FAILED 9
442
- #define NETCODE_SOCKET_ERROR_DISABLE_UDP_PORT_CONNRESET_FAILED 10
432
+ #define NETCODE_SOCKET_ERROR_NONE 0
433
+ #define NETCODE_SOCKET_ERROR_CREATE_FAILED 1
434
+ #define NETCODE_SOCKET_ERROR_SET_NON_BLOCKING_FAILED 2
435
+ #define NETCODE_SOCKET_ERROR_SOCKOPT_IPV6_ONLY_FAILED 3
436
+ #define NETCODE_SOCKET_ERROR_SOCKOPT_RCVBUF_FAILED 4
437
+ #define NETCODE_SOCKET_ERROR_SOCKOPT_SNDBUF_FAILED 5
438
+ #define NETCODE_SOCKET_ERROR_BIND_IPV4_FAILED 6
439
+ #define NETCODE_SOCKET_ERROR_BIND_IPV6_FAILED 7
440
+ #define NETCODE_SOCKET_ERROR_GET_SOCKNAME_IPV4_FAILED 8
441
+ #define NETCODE_SOCKET_ERROR_GET_SOCKNAME_IPV6_FAILED 9
442
+ #define NETCODE_SOCKET_ERROR_DISABLE_UDP_PORT_CONNRESET_FAILED 10
443
+ #define NETCODE_SOCKET_ERROR_ENABLE_PACKET_TAGGING_FAILED 11
443
444
444
445
void netcode_socket_destroy ( struct netcode_socket_t * socket )
445
446
{
@@ -640,21 +641,43 @@ int netcode_socket_create( struct netcode_socket_t * s, struct netcode_address_t
640
641
if ( setsockopt ( s -> handle , IPPROTO_IPV6 , IPV6_TCLASS , (const char * )& tos , sizeof (tos ) ) != 0 )
641
642
{
642
643
netcode_printf ( NETCODE_LOG_LEVEL_ERROR , "error: failed to enable packet tagging (ipv6)\n" );
644
+ return NETCODE_SOCKET_ERROR_ENABLE_PACKET_TAGGING_FAILED ;
643
645
}
644
646
}
645
647
else
646
648
{
647
649
int tos = 46 ;
648
650
if ( setsockopt ( s -> handle , IPPROTO_IP , IP_TOS , (const char * )& tos , sizeof (tos ) ) != 0 )
649
651
{
650
- netcode_printf ( NETCODE_LOG_LEVEL_DEBUG , "failed to enable packet tagging (ipv4)" );
652
+ netcode_printf ( NETCODE_LOG_LEVEL_ERROR , "error: failed to enable packet tagging (ipv4)\n" );
653
+ return NETCODE_SOCKET_ERROR_ENABLE_PACKET_TAGGING_FAILED ;
651
654
}
652
655
}
653
656
}
654
657
655
658
#elif NETCODE_PLATFORM == NETCODE_PLATFORM_LINUX
656
659
657
- // todo: linux implementation
660
+ if ( netcode_packet_tagging_enabled )
661
+ {
662
+ if ( address -> type == NETCODE_ADDRESS_IPV6 )
663
+ {
664
+ int tos = 46 ;
665
+ if ( setsockopt ( socket -> handle , IPPROTO_IPV6 , IPV6_TCLASS , (const char * )& tos , sizeof (tos ) ) != 0 )
666
+ {
667
+ netcode_printf ( NETCODE_LOG_LEVEL_ERROR , "error: failed to enable packet tagging (ipv6)\n" );
668
+ return NETCODE_SOCKET_ERROR_ENABLE_PACKET_TAGGING_FAILED ;
669
+ }
670
+ }
671
+ else
672
+ {
673
+ int tos = 46 ;
674
+ if ( setsockopt ( socket -> handle , IPPROTO_IP , IP_TOS , (const char * )& tos , sizeof (tos ) ) != 0 )
675
+ {
676
+ netcode_printf ( NETCODE_LOG_LEVEL_ERROR , "error: failed to enable packet tagging (ipv4)\n" );
677
+ return NETCODE_SOCKET_ERROR_ENABLE_PACKET_TAGGING_FAILED ;
678
+ }
679
+ }
680
+ }
658
681
659
682
#elif NETCODE_PLATFORM == NETCODE_PLATFORM_WINDOWS
660
683
@@ -3438,7 +3461,7 @@ int netcode_encryption_manager_add_encryption_mapping( struct netcode_encryption
3438
3461
for ( i = 0 ; i < NETCODE_MAX_ENCRYPTION_MAPPINGS ; i ++ )
3439
3462
{
3440
3463
if ( encryption_manager -> address [i ].type == NETCODE_ADDRESS_NONE ||
3441
- ( netcode_encryption_manager_entry_expired ( encryption_manager , i , time ) && encryption_manager -> client_index [i ] == -1 ) )
3464
+ ( netcode_encryption_manager_entry_expired ( encryption_manager , i , time ) && encryption_manager -> client_index [i ] == -1 ) )
3442
3465
{
3443
3466
encryption_manager -> timeout [i ] = timeout ;
3444
3467
encryption_manager -> address [i ] = * address ;
0 commit comments