Skip to content

Commit

Permalink
Everything converted to ipv6.
Browse files Browse the repository at this point in the history
You still can connect to ipv4 via IPv4-Mapped IPv6 Addresses.

Squashed commit of the following:

commit c559551
Author: proller <[email protected]>
Date:   Mon Oct 31 23:13:36 2016 +0300

    Everything converted to ipv6.
    You still can connect to ipv4 via IPv4-Mapped IPv6 Addresses.

    Incompatible lib ABI.

    Squashed commit of the following:

    commit d643eb3
    Merge: c3fec7a 9ce6c59
    Author: proller <[email protected]>
    Date:   Mon Oct 31 23:06:18 2016 +0300

        Merge branch 'master' into ipv6

    commit c3fec7a
    Merge: 1f8eb62 f46fee0
    Author: proller <[email protected]>
    Date:   Fri Sep 16 13:16:45 2016 +0300

        Merge remote-tracking branch 'upstream/master' into ipv6

    commit 1f8eb62
    Author: proller <[email protected]>
    Date:   Sat Mar 12 02:11:52 2016 +0300

        support sin6_scope_id in address

    commit f499bc5
    Merge: 720e7c4 4d10671
    Author: proller <[email protected]>
    Date:   Sat Mar 12 01:14:00 2016 +0300

        Merge remote-tracking branch 'upstream/master' into ipv6

    commit 720e7c4
    Author: proller <[email protected]>
    Date:   Thu Dec 17 01:17:38 2015 +0300

        return setting ENET_SOCKOPT_IPV6_V6ONLY=>0 after bind

    commit b048473
    Author: proller <[email protected]>
    Date:   Sat Sep 26 11:40:41 2015 +0400

        fix win32 compiler warning

    commit 5a9492d
    Merge: 09018e4 2a567b0
    Author: proller <[email protected]>
    Date:   Tue Aug 25 18:12:34 2015 +0300

        Merge pull request #1 from K-os/ipv6

        Allow connecting to IPv4 addresses

    commit 2a567b0
    Author: Gabriel Hege <[email protected]>
    Date:   Mon Aug 24 12:07:09 2015 +0200

        Set socket option IPV6_V6ONLY before bind()

    commit 2b52599
    Author: Gabriel Hege <[email protected]>
    Date:   Mon Aug 24 12:11:09 2015 +0200

        Handle IPv4/v6 addresses returend from getaddrinfo

    commit a91524f
    Author: Gabriel Hege <[email protected]>
    Date:   Thu Aug 13 19:25:17 2015 +0200

        gethostbyname(): Use correct address family AF_INET6

        for result from gethostbyname()

    commit 90620b2
    Author: Gabriel Hege <[email protected]>
    Date:   Thu Aug 13 19:26:41 2015 +0200

        Fail or Warn, when getaddrinfo(), inet_pton() and friends are missing

    commit 09018e4
    Author: proller <[email protected]>
    Date:   Mon May 11 22:03:48 2015 +0300

        fix

    commit a2651c6
    Merge: 2c1bac4 62755b1
    Author: proller <[email protected]>
    Date:   Mon May 11 20:28:46 2015 +0300

        Merge branch 'master' into ipv6

        Conflicts:
        	unix.c

    commit 2c1bac4
    Author: proller <[email protected]>
    Date:   Mon May 11 17:53:49 2015 +0300

        add IPV6_V6ONLY socket option = 0

    commit 52b0da7
    Author: proller <[email protected]>
    Date:   Tue May 5 22:37:06 2015 +0400

        very ugly win32 fix

    commit 1394392
    Merge: e236d01 b1758c4
    Author: proller <[email protected]>
    Date:   Mon May 4 22:45:36 2015 +0300

        Merge branch 'master' into ipv6

    commit e236d01
    Author: proller <[email protected]>
    Date:   Mon May 4 19:41:47 2015 +0400

        fix aton types

    commit 0ff6534
    Merge: cf46ab3 c10af34
    Author: proller <[email protected]>
    Date:   Fri Apr 10 23:40:21 2015 +0300

        Merge remote-tracking branch 'origin/master' into ipv6

        Conflicts:
        	include/enet/win32.h

    commit cf46ab3
    Author: proller <[email protected]>
    Date:   Mon Apr 6 03:20:12 2015 +0300

        win32: fix include order

    commit b9de5d2
    Merge: 3f5bab2 a2eb357
    Author: proller <[email protected]>
    Date:   Sun Apr 5 03:38:19 2015 +0300

        Merge branch 'master' into ipv6

        Conflicts:
        	unix.c

    commit 3f5bab2
    Author: proller <[email protected]>
    Date:   Fri Jan 9 21:05:50 2015 +0300

        fix inet_ntoa

    commit 7d9fa2b
    Author: proller <[email protected]>
    Date:   Tue Dec 16 23:53:47 2014 +0300

        fix win32 build errors

    commit 04394e6
    Author: proller <[email protected]>
    Date:   Wed Dec 3 01:07:18 2014 +0300

        apple fix

    commit 9122c46
    Merge: b3f2bf9 b8ae4a1
    Author: proller <[email protected]>
    Date:   Wed Dec 3 01:01:51 2014 +0300

        Merge branch 'master' into ipv6

    commit b3f2bf9
    Merge: 512a43b 8096edb
    Author: proller <[email protected]>
    Date:   Wed Oct 8 17:07:54 2014 +0400

        Merge branch 'master' into ipv6

    commit 512a43b
    Author: proller <[email protected]>
    Date:   Thu Jul 3 18:46:25 2014 +0400

        Copypaste resolving functions from unix.c to win32.c

    commit dce98b9
    Author: proller <[email protected]>
    Date:   Wed May 21 01:21:39 2014 +0400

        ENET_IPV6 flag

    commit db8fb8c
    Author: proller <[email protected]>
    Date:   Wed May 21 00:25:51 2014 +0400

        Try to add windows tcpip headers

    commit 28c5f1e
    Merge: 3963c69 06b535c
    Author: proller <[email protected]>
    Date:   Mon May 12 01:00:21 2014 +0400

        Merge branch 'master' into ipv6

    commit 3963c69
    Merge: 3586b8a 47c8379
    Author: proller <[email protected]>
    Date:   Mon May 12 00:56:06 2014 +0400

        Merge remote-tracking branch 'origin/master' into ipv6

    commit 3586b8a
    Author: proller <[email protected]>
    Date:   Thu Apr 10 23:50:10 2014 +0400

        win32 convert, unfinished

    commit 3d27904
    Author: proller <[email protected]>
    Date:   Thu Apr 10 23:20:32 2014 +0400

        ipv6 support

    commit 54d2681
    Author: proller <[email protected]>
    Date:   Thu Apr 10 22:56:28 2014 +0400

        add CMakeLists.txt

commit 9ce6c59
Merge: 62755b1 f46fee0
Author: proller <[email protected]>
Date:   Mon Oct 31 23:05:11 2016 +0300

    Merge remote-tracking branch 'upstream/master'

commit 62755b1
Merge: b1758c4 5f47654
Author: proller <[email protected]>
Date:   Mon May 11 18:02:12 2015 +0300

    Merge remote-tracking branch 'enet/master'

commit b1758c4
Merge: c10af34 f7c46f0
Author: proller <[email protected]>
Date:   Mon May 4 22:45:11 2015 +0300

    Merge remote-tracking branch 'enet/master'

commit c10af34
Author: proller <[email protected]>
Date:   Fri Apr 10 23:39:21 2015 +0300

    fix windows compiler warning

commit a2eb357
Merge: b8ae4a1 7c27a5d
Author: proller <[email protected]>
Date:   Sun Apr 5 03:33:47 2015 +0300

    Merge remote-tracking branch 'upstream/master'

commit b8ae4a1
Merge: 8096edb c8fa0ae
Author: proller <[email protected]>
Date:   Wed Dec 3 01:01:02 2014 +0300

    Merge remote-tracking branch 'upstream/master'

commit 8096edb
Merge: 4133fd2 6ef4e7d
Author: proller <[email protected]>
Date:   Wed Oct 8 17:07:07 2014 +0400

    Merge remote-tracking branch 'upstream/master'

commit 4133fd2
Author: proller <[email protected]>
Date:   Thu Apr 10 22:56:28 2014 +0400

    add CMakeLists.txt

commit eba42ff
Author: proller <[email protected]>
Date:   Wed May 21 00:35:29 2014 +0400

    Revert "Try to add windows tcpip headers"

    This reverts commit 9008b3c.

commit 9008b3c
Author: proller <[email protected]>
Date:   Wed May 21 00:25:51 2014 +0400

    Try to add windows tcpip headers

commit 06b535c
Merge: 47c8379 736474c
Author: proller <[email protected]>
Date:   Mon May 12 00:59:43 2014 +0400

    Merge remote-tracking branch 'upstream/master'

commit 47c8379
Author: proller <[email protected]>
Date:   Mon May 12 00:55:31 2014 +0400

    .gitignore
  • Loading branch information
proller committed Oct 31, 2016
1 parent 12505b2 commit aefa2bd
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 109 deletions.
6 changes: 5 additions & 1 deletion host.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
memset (host -> peers, 0, peerCount * sizeof (ENetPeer));

host -> socket = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM);
if (host -> socket != ENET_SOCKET_NULL)
enet_socket_set_option (host -> socket, ENET_SOCKOPT_IPV6_V6ONLY, 0);
if (host -> socket == ENET_SOCKET_NULL || (address != NULL && enet_socket_bind (host -> socket, address) < 0))
{
if (host -> socket != ENET_SOCKET_NULL)
Expand All @@ -64,6 +66,8 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
enet_socket_set_option (host -> socket, ENET_SOCKOPT_BROADCAST, 1);
enet_socket_set_option (host -> socket, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE);
enet_socket_set_option (host -> socket, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE);
enet_socket_set_option (host -> socket, ENET_SOCKOPT_IPV6_V6ONLY, 0);


if (address != NULL && enet_socket_get_address (host -> socket, & host -> address) < 0)
host -> address = * address;
Expand All @@ -87,7 +91,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
host -> commandCount = 0;
host -> bufferCount = 0;
host -> checksum = NULL;
host -> receivedAddress.host = ENET_HOST_ANY;
host -> receivedAddress.host = in6addr_any;
host -> receivedAddress.port = 0;
host -> receivedData = NULL;
host -> receivedDataLength = 0;
Expand Down
9 changes: 7 additions & 2 deletions include/enet/enet.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ typedef enum _ENetSocketOption
ENET_SOCKOPT_RCVTIMEO = 6,
ENET_SOCKOPT_SNDTIMEO = 7,
ENET_SOCKOPT_ERROR = 8,
ENET_SOCKOPT_NODELAY = 9
ENET_SOCKOPT_NODELAY = 9,
ENET_SOCKOPT_IPV6_V6ONLY = 10
} ENetSocketOption;

typedef enum _ENetSocketShutdown
Expand All @@ -72,6 +73,7 @@ typedef enum _ENetSocketShutdown
ENET_SOCKET_SHUTDOWN_READ_WRITE = 2
} ENetSocketShutdown;

#define ENET_IPV6 1
#define ENET_HOST_ANY 0
#define ENET_HOST_BROADCAST 0xFFFFFFFFU
#define ENET_PORT_ANY 0
Expand All @@ -88,10 +90,13 @@ typedef enum _ENetSocketShutdown
*/
typedef struct _ENetAddress
{
enet_uint32 host;
struct in6_addr host;
enet_uint16 port;
enet_uint16 sin6_scope_id;
} ENetAddress;

#define in6_equal(in6_addr_a, in6_addr_b) (memcmp(&in6_addr_a, &in6_addr_b, sizeof(struct in6_addr)) == 0)

/**
* Packet flag bit constants.
*
Expand Down
11 changes: 11 additions & 0 deletions include/enet/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@
#endif
#endif


#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <stdlib.h>
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>

typedef SOCKET ENetSocket;

Expand Down
6 changes: 3 additions & 3 deletions protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
}
else
if (currentPeer -> state != ENET_PEER_STATE_CONNECTING &&
currentPeer -> address.host == host -> receivedAddress.host)
in6_equal(currentPeer -> address.host , host -> receivedAddress.host))
{
if (currentPeer -> address.port == host -> receivedAddress.port &&
currentPeer -> connectID == command -> connect.connectID)
Expand Down Expand Up @@ -1010,9 +1010,9 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)

if (peer -> state == ENET_PEER_STATE_DISCONNECTED ||
peer -> state == ENET_PEER_STATE_ZOMBIE ||
((host -> receivedAddress.host != peer -> address.host ||
((!in6_equal(host -> receivedAddress.host , peer -> address.host) ||
host -> receivedAddress.port != peer -> address.port) &&
peer -> address.host != ENET_HOST_BROADCAST) ||
1 /* no broadcast in ipv6 !in6_equal(peer -> address.host , ENET_HOST_BROADCAST)*/) ||
(peer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID &&
sessionID != peer -> incomingSessionID))
return 0;
Expand Down
Loading

0 comments on commit aefa2bd

Please sign in to comment.