aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2019-03-26 01:58:03 +0100
committerStapleButter <thetotalworm@gmail.com>2019-03-26 01:58:03 +0100
commitf86782cc2e2a69c006ff969560a64b4e51c55526 (patch)
tree60e757810ec5eee96b6aed8f077b7eb66fbc05e3 /src
parentd67437a11ec91142ea334e6b9b4677c6bbb426ad (diff)
make it compile under Linux.
it shits itself tho.
Diffstat (limited to 'src')
-rw-r--r--src/libui_sdl/LAN_PCap.cpp2
-rw-r--r--src/libui_sdl/LAN_Socket.cpp19
2 files changed, 12 insertions, 9 deletions
diff --git a/src/libui_sdl/LAN_PCap.cpp b/src/libui_sdl/LAN_PCap.cpp
index c7f3a5a..9d4f68c 100644
--- a/src/libui_sdl/LAN_PCap.cpp
+++ b/src/libui_sdl/LAN_PCap.cpp
@@ -23,7 +23,7 @@
#include <string.h>
#include <SDL2/SDL.h>
#include <pcap/pcap.h>
-#include "Wifi.h"
+#include "../Wifi.h"
#include "LAN_PCap.h"
#include "PlatformConfig.h"
diff --git a/src/libui_sdl/LAN_Socket.cpp b/src/libui_sdl/LAN_Socket.cpp
index 3f362ca..a9f2cd7 100644
--- a/src/libui_sdl/LAN_Socket.cpp
+++ b/src/libui_sdl/LAN_Socket.cpp
@@ -21,7 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "Wifi.h"
+#include "../Wifi.h"
#include "LAN_Socket.h"
#include "../Config.h"
@@ -34,8 +34,10 @@
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
+ #include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>
+ #include <netdb.h>
#define socket_t int
#define sockaddr_t struct sockaddr
#define closesocket close
@@ -82,7 +84,7 @@ typedef struct
// 1: connected
u8 Status;
- SOCKET Backend;
+ socket_t Backend;
} TCPSocket;
@@ -92,7 +94,7 @@ typedef struct
u16 SourcePort;
u16 DestPort;
- SOCKET Backend;
+ socket_t Backend;
struct sockaddr_in BackendAddr;
} UDPSocket;
@@ -456,11 +458,12 @@ void HandleDNSFrame(u8* data, int len)
while (p)
{
struct sockaddr_in* addr = (struct sockaddr_in*)p->ai_addr;
- printf(" -> %d.%d.%d.%d",
+ /*printf(" -> %d.%d.%d.%d",
addr->sin_addr.S_un.S_un_b.s_b1, addr->sin_addr.S_un.S_un_b.s_b2,
- addr->sin_addr.S_un.S_un_b.s_b3, addr->sin_addr.S_un.S_un_b.s_b4);
+ addr->sin_addr.S_un.S_un_b.s_b3, addr->sin_addr.S_un.S_un_b.s_b4);*/
- addr_res = addr->sin_addr.S_un.S_addr;
+ //addr_res = addr->sin_addr.S_un.S_addr;
+ addr_res = *(u32*)&addr->sin_addr;
p = p->ai_next;
}
}
@@ -601,7 +604,7 @@ void HandleUDPFrame(u8* data, int len)
sock->BackendAddr.sin_family = AF_INET;
sock->BackendAddr.sin_port = htons(dstport);
memcpy(&sock->BackendAddr.sin_addr, &ipheader[16], 4);
- /*if (bind(sock->Backend, (struct sockaddr*)&sock->BackendAddr, sizeof(sock->BackendAddr)) == SOCKET_ERROR)
+ /*if (bind(sock->Backend, (struct sockaddr*)&sock->BackendAddr, sizeof(sock->BackendAddr)) == -1)
{
printf("bind() shat itself :(\n");
}*/
@@ -869,7 +872,7 @@ void HandleTCPFrame(u8* data, int len)
conn_addr.sin_family = AF_INET;
memcpy(&conn_addr.sin_addr, &ipheader[16], 4);
conn_addr.sin_port = htons(dstport);
- if (connect(sock->Backend, (sockaddr*)&conn_addr, sizeof(conn_addr)) == SOCKET_ERROR)
+ if (connect(sock->Backend, (sockaddr*)&conn_addr, sizeof(conn_addr)) == -1)
{
printf("connect() shat itself :(\n");
}