Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10 from MurphyMarkW/mwm-patch-ipv6
Browse files Browse the repository at this point in the history
AF_UNSPEC to AF_INET -- ignoring IPv6 for now.
  • Loading branch information
MurphyMarkW committed Mar 23, 2015
2 parents 75db1de + 014d0f4 commit 5ebffae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/nydus/nydus.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ volatile const char * udt_source_port = "9000";
volatile const char * tcp_target_host = "localhost";
volatile const char * tcp_target_port = "9090";

volatile const char * udt_target_host = "0.0.0.0";
volatile const char * udt_target_host = "localhost";
volatile const char * udt_target_port = "9090";


Expand Down
10 changes: 7 additions & 3 deletions src/nydus/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void * tcp_handler(void * canal) {

// Look up the destination information.
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6
hints.ai_family = AF_INET; // Allow IPv4 (IPv6 soon)
hints.ai_socktype = SOCK_STREAM; // Request TCP socket
hints.ai_flags = AI_PASSIVE; // Whatever interface for now.
hints.ai_protocol = 0;
Expand Down Expand Up @@ -60,7 +60,7 @@ static void * tcp_handler(void * canal) {
// Connect to the other side.
if(udt.connect(sock, curr->ai_addr, curr->ai_addrlen)) {
syslog(LOG_WARNING, fmt("Failed to connect to target server."));
syslog(LOG_WARNING, fmt("UDT SOCKET ERROR GOES HERE"));
syslog(LOG_WARNING, fmt("UDT error code: %u"), udt.getlasterror_code());
close(sock);
continue;
}
Expand All @@ -72,6 +72,8 @@ static void * tcp_handler(void * canal) {
syslog(LOG_ERR, fmt("Could not build a socket."));
goto cleanup;
}

syslog(LOG_INFO, fmt("UDT connection established."));

// Create a new canal data structure.
struct canal * target = (struct canal *)malloc(sizeof(struct canal));
Expand All @@ -90,8 +92,10 @@ static void * tcp_handler(void * canal) {
freeaddrinfo(info); // NOTE this doesn't set NULL and not idempotent
info = NULL;

syslog(LOG_INFO, fmt("Closing UDT connection."));
udt.close(sock);

syslog(LOG_INFO, fmt("Closing TCP connection."));
close(((struct canal *)canal)->source_sock);
free(canal);

Expand Down Expand Up @@ -159,7 +163,7 @@ void * tcp_proxy(void * canal) {

// Look up the server information.
memset(&hint, 0, sizeof(struct addrinfo));
hint.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6
hint.ai_family = AF_INET; // Allow IPv4 (IPv6 soon)
hint.ai_socktype = SOCK_STREAM; // Request TCP socket
hint.ai_flags = AI_PASSIVE; // Whatever interface for now.
hint.ai_protocol = 0;
Expand Down
8 changes: 6 additions & 2 deletions src/nydus/udt.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void * udt_handler(void * canal) {

// Look up the destination information.
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6
hints.ai_family = AF_INET; // Allow IPv4 (IPv6 soon)
hints.ai_socktype = SOCK_STREAM; // Request TCP socket
hints.ai_flags = AI_PASSIVE; // Whatever interface for now.
hints.ai_protocol = 0;
Expand Down Expand Up @@ -72,6 +72,8 @@ static void * udt_handler(void * canal) {
syslog(LOG_ERR, fmt("Could not build a socket."));
goto cleanup;
}

syslog(LOG_INFO, fmt("TCP connection established."));

// Create a new canal data structure.
struct canal * target = (struct canal *)malloc(sizeof(struct canal));
Expand All @@ -90,8 +92,10 @@ static void * udt_handler(void * canal) {
freeaddrinfo(info); // NOTE this doesn't set NULL and not idempotent
info = NULL;

syslog(LOG_INFO, fmt("Closing TCP connection."));
close(sock);

syslog(LOG_INFO, fmt("Closing UDT connection."));
udt.close(((struct canal *)canal)->source_sock);
free(canal);

Expand Down Expand Up @@ -159,7 +163,7 @@ void * udt_proxy (void * canal) {

// Look up the server information.
memset(&hint, 0, sizeof(struct addrinfo));
hint.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6
hint.ai_family = AF_INET; // Allow IPv4 (IPv6 soon)
hint.ai_socktype = SOCK_STREAM; // Request UDT socket
hint.ai_flags = AI_PASSIVE; // Whatever interface for now.
hint.ai_protocol = 0;
Expand Down

0 comments on commit 5ebffae

Please sign in to comment.