![]() |
DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
|
|
#include "darkplaces.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include "zone.h"
#include "sys.h"
#include "netconn.h"
#include "lhnet.h"
Go to the source code of this file.
Data Structures | |
struct | lhnetaddressnative_t |
struct | lhnetpacket_t |
struct | namecache_s |
Macros | |
#define | closesocket close |
#define | ioctlsocket ioctl |
#define | LHNET_RECVFROM_FLAGS 0 |
#define | LHNET_SENDTO_FLAGS 0 |
#define | MAX_NAMECACHE 64 |
#define | SOCKETERRNO errno |
#define | SOCKLEN_T socklen_t |
Variables | |
static int | lhnet_active |
static int | lhnet_default_dscp = 0 |
static lhnetpacket_t | lhnet_packetlist |
lhnetsocket_t | lhnet_socketlist |
static struct namecache_s | namecache [MAX_NAMECACHE] |
static int | namecacheposition = 0 |
#define closesocket close |
Definition at line 84 of file lhnet.c.
Referenced by LHNET_CloseSocket(), and LHNET_OpenSocket_Connectionless().
#define ioctlsocket ioctl |
Definition at line 83 of file lhnet.c.
Referenced by LHNET_OpenSocket_Connectionless().
#define LHNET_RECVFROM_FLAGS 0 |
Definition at line 94 of file lhnet.c.
Referenced by LHNET_Read().
#define LHNET_SENDTO_FLAGS 0 |
Definition at line 95 of file lhnet.c.
Referenced by LHNET_Write().
#define MAX_NAMECACHE 64 |
Definition at line 115 of file lhnet.c.
Referenced by LHNETADDRESS_FromString().
#define SOCKETERRNO errno |
Definition at line 85 of file lhnet.c.
Referenced by LHNET_OpenSocket_Connectionless(), LHNET_Read(), and LHNET_Write().
#define SOCKLEN_T socklen_t |
Definition at line 87 of file lhnet.c.
Referenced by LHNET_OpenSocket_Connectionless(), and LHNET_Read().
lhnetaddress_t * LHNET_AddressFromSocket | ( | lhnetsocket_t * | sock | ) |
Definition at line 1026 of file lhnet.c.
References lhnetsocket_t::address, and NULL.
Referenced by NetConn_ChooseClientSocketForAddress(), NetConn_ChooseServerSocketForAddress(), NetConn_OpenClientPort(), NetConn_OpenServerPort(), NetConn_Read(), NetConn_ServerParsePacket(), and NetConn_Write().
void LHNET_CloseSocket | ( | lhnetsocket_t * | lhnetsocket | ) |
Definition at line 1012 of file lhnet.c.
References lhnetsocket_t::address, lhnetaddress_t::addresstype, closesocket, lhnetsocket_t::inetsocket, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, lhnetsocket_t::list, List_Delete(), and Z_Free.
Referenced by LHNET_Shutdown(), NetConn_CloseClientPorts(), and NetConn_CloseServerPorts().
Definition at line 739 of file lhnet.c.
References lhnet_default_dscp.
Referenced by NetConn_UpdateSockets().
Definition at line 725 of file lhnet.c.
References Con_Print(), lhnet_active, lhnet_packetlist, lhnet_socketlist, lhnetpacket_t::list, lhnetsocket_t::list, and List_Create().
Referenced by NetConn_Init().
lhnetsocket_t * LHNET_OpenSocket_Connectionless | ( | lhnetaddress_t * | address | ) |
Definition at line 832 of file lhnet.c.
References lhnetaddressnative_t::addr, lhnetsocket_t::address, lhnetaddress_t::addresstype, closesocket, Con_DPrintf(), CON_ERROR, Con_Print(), Con_Printf(), i, lhnetaddressnative_t::in, lhnetaddressnative_t::in6, lhnetsocket_t::inetsocket, ioctlsocket, lhnet_default_dscp, lhnet_socketlist, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, LHNETADDRESSTYPE_LOOP, LHNETPRIVATE_StrError(), lhnetsocket_t::list, List_Add_Tail(), List_For_Each_Entry, NULL, lhnetaddress_t::port, lhnetaddressnative_t::sock, SOCKETERRNO, SOCKLEN_T, Z_Free, and Z_Malloc.
Referenced by NetConn_OpenClientPort(), and NetConn_OpenServerPort().
int LHNET_Read | ( | lhnetsocket_t * | lhnetsocket, |
void * | content, | ||
int | maxcontentlength, | ||
lhnetaddress_t * | vaddress ) |
Definition at line 1034 of file lhnet.c.
References lhnetaddressnative_t::addr, lhnetsocket_t::address, lhnetaddress_t::addresstype, lhnetaddressnative_t::addresstype, Con_DPrintf(), Con_Print(), lhnetpacket_t::data, lhnetpacket_t::destinationport, host, lhnetaddressnative_t::in, lhnetaddressnative_t::in6, lhnetsocket_t::inetsocket, lhnetpacket_t::length, lhnet_packetlist, LHNET_RECVFROM_FLAGS, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, LHNETADDRESSTYPE_LOOP, LHNETADDRESSTYPE_NONE, LHNETPRIVATE_StrError(), lhnetpacket_t::list, List_Delete(), List_For_Each_Entry_Safe, net_fakelag, NULL, lhnetaddress_t::port, lhnetaddressnative_t::port, host_static_t::realtime, lhnetpacket_t::sentdoubletime, lhnetaddressnative_t::sock, SOCKETERRNO, SOCKLEN_T, lhnetpacket_t::sourceport, time, lhnetpacket_t::timeout, cvar_t::value, value, and Z_Free.
Referenced by NetConn_Read().
Definition at line 751 of file lhnet.c.
References lhnet_active, LHNET_CloseSocket(), lhnet_packetlist, lhnet_socketlist, lhnetpacket_t::list, lhnetsocket_t::list, List_Delete(), List_For_Each_Entry_Safe, and Z_Free.
Referenced by NetConn_Shutdown().
int LHNET_Write | ( | lhnetsocket_t * | lhnetsocket, |
const void * | content, | ||
int | contentlength, | ||
const lhnetaddress_t * | vaddress ) |
Definition at line 1135 of file lhnet.c.
References lhnetaddressnative_t::addr, lhnetsocket_t::address, lhnetaddress_t::addresstype, lhnetaddressnative_t::addresstype, Con_DPrintf(), lhnetpacket_t::data, lhnetpacket_t::destinationport, host, lhnetaddressnative_t::in, lhnetaddressnative_t::in6, lhnetsocket_t::inetsocket, lhnetpacket_t::length, lhnet_packetlist, LHNET_SENDTO_FLAGS, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, LHNETADDRESSTYPE_LOOP, LHNETPRIVATE_StrError(), lhnetpacket_t::list, List_Add_Tail(), NULL, lhnetaddress_t::port, lhnetaddressnative_t::port, host_static_t::realtime, lhnetpacket_t::sentdoubletime, SOCKETERRNO, lhnetpacket_t::sourceport, time, lhnetpacket_t::timeout, value, and Z_Malloc.
Referenced by NetConn_Write().
int LHNETADDRESS_Compare | ( | const lhnetaddress_t * | vaddress1, |
const lhnetaddress_t * | vaddress2 ) |
Definition at line 665 of file lhnet.c.
References lhnetaddressnative_t::addr, lhnetaddressnative_t::addresstype, lhnetaddressnative_t::in, lhnetaddressnative_t::in6, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, LHNETADDRESSTYPE_LOOP, and lhnetaddressnative_t::port.
Referenced by CL_Rcon_f(), Crypto_ClearHostKey(), Crypto_ClientParsePacket(), Crypto_RetrieveHostKey(), Crypto_ServerFindInstance(), Crypto_ServerParsePacket_Internal(), Crypto_StoreHostKey(), hmac_mdfour_challenge_matching(), NetConn_ClearFlood(), NetConn_ClientParsePacket(), NetConn_PreventFlood(), and NetConn_ServerParsePacket().
int LHNETADDRESS_FromPort | ( | lhnetaddress_t * | vaddress, |
lhnetaddresstype_t | addresstype, | ||
int | port ) |
Definition at line 125 of file lhnet.c.
References lhnetaddressnative_t::addr, lhnetaddressnative_t::addresstype, lhnetaddressnative_t::in, lhnetaddressnative_t::in6, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, LHNETADDRESSTYPE_LOOP, and lhnetaddressnative_t::port.
Referenced by NetConn_OpenClientPort(), and NetConn_OpenServerPort().
int LHNETADDRESS_FromString | ( | lhnetaddress_t * | vaddress, |
const char * | string, | ||
int | defaultport ) |
Definition at line 204 of file lhnet.c.
References a, lhnetaddressnative_t::addr, namecache_s::address, lhnetaddressnative_t::addresstype, Con_Printf(), namecache_s::expirationtime, host, i, lhnetaddressnative_t::in, lhnetaddressnative_t::in6, int(), LHNETADDRESS_Resolve(), LHNETADDRESS_ToString(), LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, LHNETADDRESSTYPE_LOOP, LHNETADDRESSTYPE_NONE, MAX_NAMECACHE, name, namecache_s::name, namecache, namecacheposition, NULL, lhnetaddressnative_t::port, host_static_t::realtime, string, and strlen().
Referenced by CL_EstablishConnection(), CL_Packet_f(), CL_PQRcon_f(), CL_Rcon_f(), Crypto_HostKey_Clear_f(), Log_DestBuffer_Flush_NoLock(), NetConn_Heartbeat(), NetConn_Init(), NetConn_OpenClientPort(), NetConn_OpenServerPort(), VM_M_crypto_getencryptlevel(), VM_M_crypto_getidfp(), VM_M_crypto_getidstatus(), VM_M_crypto_getkeyfp(), and VM_netaddress_resolve().
const char * LHNETADDRESS_GetInterfaceName | ( | const lhnetaddress_t * | vaddress, |
char * | ifname, | ||
size_t | ifnamelength ) |
Definition at line 608 of file lhnet.c.
References lhnetaddressnative_t::addr, lhnetaddressnative_t::addresstype, dpsnprintf(), lhnetaddressnative_t::in6, LHNETADDRESSTYPE_INET6, and NULL.
int LHNETADDRESS_GetPort | ( | const lhnetaddress_t * | address | ) |
Definition at line 635 of file lhnet.c.
References lhnetaddress_t::port.
Referenced by NetConn_ServerParsePacket().
|
static |
Definition at line 163 of file lhnet.c.
References lhnetaddressnative_t::addr, lhnetaddressnative_t::addresstype, dpsnprintf(), lhnetaddressnative_t::in, lhnetaddressnative_t::in6, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, name, NULL, and lhnetaddressnative_t::port.
Referenced by LHNETADDRESS_FromString().
int LHNETADDRESS_SetPort | ( | lhnetaddress_t * | vaddress, |
int | port ) |
Definition at line 642 of file lhnet.c.
References lhnetaddressnative_t::addr, lhnetaddressnative_t::addresstype, lhnetaddressnative_t::in, lhnetaddressnative_t::in6, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, LHNETADDRESSTYPE_LOOP, and lhnetaddressnative_t::port.
Referenced by NetConn_ClearFlood(), NetConn_ClientParsePacket(), and NetConn_PreventFlood().
int LHNETADDRESS_ToString | ( | const lhnetaddress_t * | vaddress, |
char * | string, | ||
int | stringbuffersize, | ||
int | includeport ) |
Returns the number of bytes written to *string excluding the \0 terminator.
Definition at line 540 of file lhnet.c.
References a, lhnetaddressnative_t::addr, lhnetaddressnative_t::addresstype, dpsnprintf(), lhnetaddressnative_t::in, lhnetaddressnative_t::in6, LHNETADDRESSTYPE_INET4, LHNETADDRESSTYPE_INET6, LHNETADDRESSTYPE_LOOP, and lhnetaddressnative_t::port.
Referenced by CL_Rcon_f(), Crypto_ClearHostKey(), Crypto_HostKeys_f(), Crypto_RetrieveHostKey(), Crypto_StoreHostKey(), LHNETADDRESS_FromString(), NetConn_ClientFrame(), NetConn_ClientParsePacket(), NetConn_Open(), NetConn_OpenClientPort(), NetConn_OpenServerPort(), NetConn_Read(), NetConn_ServerParsePacket(), NetConn_UpdateSockets(), NetConn_Write(), SV_SendServerinfo(), SVVM_init_edict(), and VM_netaddress_resolve().
|
static |
Definition at line 774 of file lhnet.c.
References i.
Referenced by LHNET_OpenSocket_Connectionless(), LHNET_Read(), and LHNET_Write().
|
static |
Definition at line 716 of file lhnet.c.
Referenced by LHNET_Init(), and LHNET_Shutdown().
|
static |
Definition at line 719 of file lhnet.c.
Referenced by LHNET_DefaultDSCP(), and LHNET_OpenSocket_Connectionless().
|
static |
Definition at line 718 of file lhnet.c.
Referenced by LHNET_Init(), LHNET_Read(), LHNET_Shutdown(), and LHNET_Write().
lhnetsocket_t lhnet_socketlist |
Definition at line 717 of file lhnet.c.
Referenced by LHNET_Init(), LHNET_OpenSocket_Connectionless(), LHNET_Shutdown(), and Sys_Sleep().
|
static |
Referenced by LHNETADDRESS_FromString().
|
static |
Definition at line 123 of file lhnet.c.
Referenced by LHNETADDRESS_FromString().