+++ /dev/null
-/*
-Copyright (C) 1996-1997 Id Software, Inc.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-#include "quakedef.h"
-
-#include "net_loop.h"
-#include "net_dgrm.h"
-
-net_driver_t net_drivers[MAX_NET_DRIVERS] =
-{
- {
- "Loopback",
- false,
- Loop_Init,
- Loop_Listen,
- Loop_SearchForHosts,
- Loop_SearchForInetHosts,
- Loop_Connect,
- Loop_CheckNewConnections,
- Loop_GetMessage,
- Loop_SendMessage,
- Loop_SendUnreliableMessage,
- Loop_CanSendMessage,
- Loop_CanSendUnreliableMessage,
- Loop_Close,
- Loop_Shutdown,
- Loop_Heartbeat
- }
- ,
- {
- "Datagram",
- false,
- Datagram_Init,
- Datagram_Listen,
- Datagram_SearchForHosts,
- Datagram_SearchForInetHosts,
- Datagram_Connect,
- Datagram_CheckNewConnections,
- Datagram_GetMessage,
- Datagram_SendMessage,
- Datagram_SendUnreliableMessage,
- Datagram_CanSendMessage,
- Datagram_CanSendUnreliableMessage,
- Datagram_Close,
- Datagram_Shutdown,
- Datagram_Heartbeat
- }
-};
-
-int net_numdrivers = 2;
-
-
-#include "net_wins.h"
-
-net_landriver_t net_landrivers[MAX_NET_DRIVERS] =
-{
- {
- "Winsock TCPIP",
- false,
- 0,
- WINS_Init,
- WINS_Shutdown,
- WINS_Listen,
- WINS_OpenSocket,
- WINS_CloseSocket,
- WINS_Connect,
- WINS_CheckNewConnections,
- WINS_Recv,
- WINS_Send,
- WINS_Read,
- WINS_Write,
- WINS_Broadcast,
- WINS_AddrToString,
- WINS_StringToAddr,
- WINS_GetSocketAddr,
- WINS_GetNameFromAddr,
- WINS_GetAddrFromName,
- WINS_AddrCompare,
- WINS_GetSocketPort,
- WINS_SetSocketPort
- }
-};
-
-int net_numlandrivers = 1;
-
static unsigned long myAddr;
-#include "net_wins.h"
+#include "net_udp.h"
WSADATA winsockdata;
}
-void WINS_GetLocalAddress(void)
+void UDP_GetLocalAddress(void)
{
struct hostent *local = NULL;
char buff[MAXHOSTNAMELEN];
}
-int WINS_Init (void)
+int UDP_Init (void)
{
int i;
char buff[MAXHOSTNAMELEN];
strcpy(my_tcpip_address, "INADDR_ANY");
}
- if ((net_controlsocket = WINS_OpenSocket (0)) == -1)
+ if ((net_controlsocket = UDP_OpenSocket (0)) == -1)
{
- Con_Printf("WINS_Init: Unable to open control socket\n");
+ Con_Printf("UDP_Init: Unable to open control socket\n");
WSACleanup ();
return -1;
}
//=============================================================================
-void WINS_Shutdown (void)
+void UDP_Shutdown (void)
{
- WINS_Listen (false);
- WINS_CloseSocket (net_controlsocket);
+ UDP_Listen (false);
+ UDP_CloseSocket (net_controlsocket);
WSACleanup ();
}
//=============================================================================
-void WINS_Listen (qboolean state)
+void UDP_Listen (qboolean state)
{
// enable listening
if (state)
{
if (net_acceptsocket != -1)
return;
- WINS_GetLocalAddress();
- if ((net_acceptsocket = WINS_OpenSocket (net_hostport)) == -1)
- Sys_Error ("WINS_Listen: Unable to open accept socket\n");
+ UDP_GetLocalAddress();
+ if ((net_acceptsocket = UDP_OpenSocket (net_hostport)) == -1)
+ Sys_Error ("UDP_Listen: Unable to open accept socket\n");
return;
}
// disable listening
if (net_acceptsocket == -1)
return;
- WINS_CloseSocket (net_acceptsocket);
+ UDP_CloseSocket (net_acceptsocket);
net_acceptsocket = -1;
}
//=============================================================================
-int WINS_OpenSocket (int port)
+int UDP_OpenSocket (int port)
{
int newsocket;
struct sockaddr_in address;
if( bind (newsocket, (void *)&address, sizeof(address)) == 0)
return newsocket;
- Sys_Error ("Unable to bind to %s", WINS_AddrToString((struct qsockaddr *)&address));
+ Sys_Error ("Unable to bind to %s", UDP_AddrToString((struct qsockaddr *)&address));
ErrorReturn:
closesocket (newsocket);
return -1;
//=============================================================================
-int WINS_CloseSocket (int socket)
+int UDP_CloseSocket (int socket)
{
if (socket == net_broadcastsocket)
net_broadcastsocket = 0;
}
//=============================================================================
-int WINS_Connect (int socket, struct qsockaddr *addr)
+int UDP_Connect (int socket, struct qsockaddr *addr)
{
return 0;
}
//=============================================================================
-int WINS_CheckNewConnections (void)
+int UDP_CheckNewConnections (void)
{
char buf[4096];
//=============================================================================
-int WINS_Recv (qbyte *buf, int len, struct qsockaddr *addr)
+int UDP_Recv (qbyte *buf, int len, struct qsockaddr *addr)
{
- return WINS_Read (net_acceptsocket, buf, len, addr);
+ return UDP_Read (net_acceptsocket, buf, len, addr);
}
//=============================================================================
-int WINS_Send (qbyte *buf, int len, struct qsockaddr *addr)
+int UDP_Send (qbyte *buf, int len, struct qsockaddr *addr)
{
- return WINS_Write (net_acceptsocket, buf, len, addr);
+ return UDP_Write (net_acceptsocket, buf, len, addr);
}
//=============================================================================
-int WINS_Read (int socket, qbyte *buf, int len, struct qsockaddr *addr)
+int UDP_Read (int socket, qbyte *buf, int len, struct qsockaddr *addr)
{
int addrlen = sizeof (struct qsockaddr);
int ret;
//=============================================================================
-int WINS_MakeSocketBroadcastCapable (int socket)
+int UDP_MakeSocketBroadcastCapable (int socket)
{
int i = 1;
//=============================================================================
-int WINS_Broadcast (int socket, qbyte *buf, int len)
+int UDP_Broadcast (int socket, qbyte *buf, int len)
{
int ret;
{
if (net_broadcastsocket != 0)
Sys_Error("Attempted to use multiple broadcasts sockets\n");
- WINS_GetLocalAddress();
- ret = WINS_MakeSocketBroadcastCapable (socket);
+ UDP_GetLocalAddress();
+ ret = UDP_MakeSocketBroadcastCapable (socket);
if (ret == -1)
{
Con_Printf("Unable to make socket broadcast capable\n");
}
}
- return WINS_Write (socket, buf, len, &broadcastaddr);
+ return UDP_Write (socket, buf, len, &broadcastaddr);
}
//=============================================================================
-int WINS_Write (int socket, qbyte *buf, int len, struct qsockaddr *addr)
+int UDP_Write (int socket, qbyte *buf, int len, struct qsockaddr *addr)
{
int ret;
//=============================================================================
-char *WINS_AddrToString (const struct qsockaddr *addr)
+char *UDP_AddrToString (const struct qsockaddr *addr)
{
static char buffer[22];
int haddr;
//=============================================================================
-int WINS_StringToAddr (const char *string, struct qsockaddr *addr)
+int UDP_StringToAddr (const char *string, struct qsockaddr *addr)
{
int ha1, ha2, ha3, ha4, hp;
int ipaddr;
//=============================================================================
-int WINS_GetSocketAddr (int socket, struct qsockaddr *addr)
+int UDP_GetSocketAddr (int socket, struct qsockaddr *addr)
{
int addrlen = sizeof(struct qsockaddr);
unsigned int a;
//=============================================================================
-int WINS_GetNameFromAddr (const struct qsockaddr *addr, char *name)
+int UDP_GetNameFromAddr (const struct qsockaddr *addr, char *name)
{
struct hostent *hostentry;
return 0;
}
- strcpy (name, WINS_AddrToString (addr));
+ strcpy (name, UDP_AddrToString (addr));
return 0;
}
//=============================================================================
-int WINS_GetAddrFromName(const char *name, struct qsockaddr *addr)
+int UDP_GetAddrFromName(const char *name, struct qsockaddr *addr)
{
struct hostent *hostentry;
//=============================================================================
-int WINS_AddrCompare (const struct qsockaddr *addr1, const struct qsockaddr *addr2)
+int UDP_AddrCompare (const struct qsockaddr *addr1, const struct qsockaddr *addr2)
{
if (addr1->sa_family != addr2->sa_family)
return -1;
//=============================================================================
-int WINS_GetSocketPort (struct qsockaddr *addr)
+int UDP_GetSocketPort (struct qsockaddr *addr)
{
return ntohs(((struct sockaddr_in *)addr)->sin_port);
}
-int WINS_SetSocketPort (struct qsockaddr *addr, int port)
+int UDP_SetSocketPort (struct qsockaddr *addr, int port)
{
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)port);
return 0;
+++ /dev/null
-/*
-Copyright (C) 1996-1997 Id Software, Inc.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-// net_wins.h
-
-#ifndef NET_WINS_H
-#define NET_WINS_H
-
-int WINS_Init (void);
-void WINS_Shutdown (void);
-void WINS_Listen (qboolean state);
-int WINS_OpenSocket (int port);
-int WINS_CloseSocket (int socket);
-int WINS_Connect (int socket, struct qsockaddr *addr);
-int WINS_CheckNewConnections (void);
-int WINS_Recv (qbyte *buf, int len, struct qsockaddr *addr);
-int WINS_Send (qbyte *buf, int len, struct qsockaddr *addr);
-int WINS_Read (int socket, qbyte *buf, int len, struct qsockaddr *addr);
-int WINS_Write (int socket, qbyte *buf, int len, struct qsockaddr *addr);
-int WINS_Broadcast (int socket, qbyte *buf, int len);
-char *WINS_AddrToString (const struct qsockaddr *addr);
-int WINS_StringToAddr (const char *string, struct qsockaddr *addr);
-int WINS_GetSocketAddr (int socket, struct qsockaddr *addr);
-int WINS_GetNameFromAddr (const struct qsockaddr *addr, char *name);
-int WINS_GetAddrFromName (const char *name, struct qsockaddr *addr);
-int WINS_AddrCompare (const struct qsockaddr *addr1, const struct qsockaddr *addr2);
-int WINS_GetSocketPort (struct qsockaddr *addr);
-int WINS_SetSocketPort (struct qsockaddr *addr, int port);
-
-#endif
-