DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
lhnet.h
Go to the documentation of this file.
1
2// Written by Ashley Rose Hale (LadyHavoc) 2003-06-15 and placed into public domain.
3
4#ifndef LHNET_H
5#define LHNET_H
6
7#include <stddef.h>
8#include "com_list.h"
9
18
19typedef struct lhnetaddress_s
20{
22 int port; // used by LHNETADDRESSTYPE_LOOP
23 unsigned char storage[256]; // sockaddr_in or sockaddr_in6
24}
26
27int LHNETADDRESS_FromPort(lhnetaddress_t *address, lhnetaddresstype_t addresstype, int port);
28int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int defaultport);
30int LHNETADDRESS_ToString(const lhnetaddress_t *address, char *string, int stringbuffersize, int includeport);
32{
33 if (address)
34 return address->addresstype;
35 else
37}
38const char *LHNETADDRESS_GetInterfaceName(const lhnetaddress_t *address, char *ifname, size_t ifnamelength);
39int LHNETADDRESS_GetPort(const lhnetaddress_t *address);
40int LHNETADDRESS_SetPort(lhnetaddress_t *address, int port);
41int LHNETADDRESS_Compare(const lhnetaddress_t *address1, const lhnetaddress_t *address2);
42
43typedef struct lhnetsocket_s
44{
48}
51
52void LHNET_Init(void);
53void LHNET_Shutdown(void);
54int LHNET_DefaultDSCP(int dscp); // < 0: query; >= 0: set (returns previous value)
57void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket);
59int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength, lhnetaddress_t *address);
60int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentlength, const lhnetaddress_t *address);
61
62#endif
63
int LHNETADDRESS_ToString(const lhnetaddress_t *address, char *string, int stringbuffersize, int includeport)
Returns the number of bytes written to *string excluding the \0 terminator.
Definition lhnet.c:540
void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket)
Definition lhnet.c:1012
void LHNET_Shutdown(void)
Definition lhnet.c:751
void LHNET_Init(void)
Definition lhnet.c:725
int LHNET_DefaultDSCP(int dscp)
Definition lhnet.c:739
lhnetsocket_t * LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
Definition lhnet.c:832
int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentlength, const lhnetaddress_t *address)
Definition lhnet.c:1135
lhnetaddress_t * LHNET_AddressFromSocket(lhnetsocket_t *sock)
Definition lhnet.c:1026
lhnetsocket_t lhnet_socketlist
Definition lhnet.c:717
void LHNET_SleepUntilPacket_Microseconds(int microseconds)
lhnetaddresstype_t
Definition lhnet.h:11
@ LHNETADDRESSTYPE_INET6
Definition lhnet.h:15
@ LHNETADDRESSTYPE_NONE
Definition lhnet.h:12
@ LHNETADDRESSTYPE_INET4
Definition lhnet.h:14
@ LHNETADDRESSTYPE_LOOP
Definition lhnet.h:13
const char * LHNETADDRESS_GetInterfaceName(const lhnetaddress_t *address, char *ifname, size_t ifnamelength)
Definition lhnet.c:608
static lhnetaddresstype_t LHNETADDRESS_GetAddressType(const lhnetaddress_t *address)
Definition lhnet.h:31
int LHNETADDRESS_GetPort(const lhnetaddress_t *address)
Definition lhnet.c:635
int LHNETADDRESS_SetPort(lhnetaddress_t *address, int port)
Definition lhnet.c:642
int LHNETADDRESS_Compare(const lhnetaddress_t *address1, const lhnetaddress_t *address2)
Definition lhnet.c:665
int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength, lhnetaddress_t *address)
Definition lhnet.c:1034
int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int defaultport)
Definition lhnet.c:204
int LHNETADDRESS_FromPort(lhnetaddress_t *address, lhnetaddresstype_t addresstype, int port)
Definition lhnet.c:125
lhnetaddresstype_t addresstype
Definition lhnet.h:21
llist_t list
Definition lhnet.h:47
lhnetaddress_t address
Definition lhnet.h:45
int inetsocket
Definition lhnet.h:46