- UDP tunneling works under BeOS

- fixed BeOS compilation problems
This commit is contained in:
cebix
2001-07-15 14:19:08 +00:00
parent 3e27acb9d4
commit 52ad76b49e
8 changed files with 175 additions and 47 deletions
+14 -3
View File
@@ -56,6 +56,13 @@ using std::map;
#define MONITOR 0
#ifdef __BEOS__
#define CLOSESOCKET closesocket
#else
#define CLOSESOCKET close
#endif
// Global variables
uint8 ether_addr[6]; // Ethernet address (set by ether_init())
static bool net_open = false; // Flag: initialization succeeded, network device open (set by EtherInit())
@@ -101,7 +108,7 @@ void EtherInit(void)
sa.sin_port = htons(udp_port);
if (bind(udp_socket, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
perror("bind");
close(udp_socket);
CLOSESOCKET(udp_socket);
udp_socket = -1;
return;
}
@@ -130,12 +137,16 @@ void EtherInit(void)
// Set socket options
int on = 1;
#ifdef __BEOS__
setsockopt(udp_socket, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(on));
#else
setsockopt(udp_socket, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
ioctl(udp_socket, FIONBIO, &on);
#endif
// Start thread for packet reception
if (!ether_start_udp_thread(udp_socket)) {
close(udp_socket);
CLOSESOCKET(udp_socket);
udp_socket = -1;
return;
}
@@ -159,7 +170,7 @@ void EtherExit(void)
if (udp_tunnel) {
if (udp_socket >= 0) {
ether_stop_udp_thread();
close(udp_socket);
CLOSESOCKET(udp_socket);
udp_socket = -1;
}
} else