X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=lhnet.h;h=701045e3aa384372275c79de522ef89a0fc85ac3;hb=66d1df20a5ed5ff954d7bf9db2db23cbe304281a;hp=c865f9a9835f51b0a2766fc67af9ed22914116f4;hpb=491df26e7e8c66fab2db0c89d2017a815986c0d7;p=xonotic%2Fdarkplaces.git diff --git a/lhnet.h b/lhnet.h index c865f9a9..701045e3 100644 --- a/lhnet.h +++ b/lhnet.h @@ -4,62 +4,28 @@ #ifndef LHNET_H #define LHNET_H -#define LHNETADDRESSTYPE_NONE 0 -#define LHNETADDRESSTYPE_LOOP 1 -#define LHNETADDRESSTYPE_INET4 2 -#define LHNETADDRESSTYPE_INET6 3 - -typedef struct lhnetaddress_loop_s -{ - unsigned short port; -} -lhnetaddress_loop_t; - -#define LHNETADDRESSTYPE_INET4_FAMILY 2 -#ifdef WIN32 -#define LHNETADDRESSTYPE_INET6_FAMILY 23 -#else -#define LHNETADDRESSTYPE_INET6_FAMILY 10 -#endif - -// compatible with sockaddr_in -typedef struct lhnetaddress_inet4_s -{ - unsigned short family; // 2 - unsigned short port; - unsigned char address[4]; - unsigned char padding[8]; // to match sockaddr_in -} -lhnetaddress_inet4_t; - -// compatible with sockaddr_in6 -typedef struct lhnetaddress_inet6_s +typedef enum lhnetaddresstype_e { - unsigned short family; // 10 - unsigned short port; - unsigned int flowinfo; - unsigned short address[8]; - unsigned int scope_id; + LHNETADDRESSTYPE_NONE, + LHNETADDRESSTYPE_LOOP, + LHNETADDRESSTYPE_INET4, + LHNETADDRESSTYPE_INET6, } -lhnetaddress_inet6_t; +lhnetaddresstype_t; typedef struct lhnetaddress_s { - int addresstype; - union - { - lhnetaddress_loop_t loop; - lhnetaddress_inet4_t inet4; - lhnetaddress_inet6_t inet6; - } - addressdata; + lhnetaddresstype_t addresstype; + int port; // used by LHNETADDRESSTYPE_LOOP + unsigned char storage[256]; // sockaddr_in or sockaddr_in6 } lhnetaddress_t; -int LHNETADDRESS_FromPort(lhnetaddress_t *address, int addresstype, int port); +int LHNETADDRESS_FromPort(lhnetaddress_t *address, lhnetaddresstype_t addresstype, int port); int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int defaultport); int LHNETADDRESS_ToString(const lhnetaddress_t *address, char *string, int stringbuffersize, int includeport); int LHNETADDRESS_GetAddressType(const lhnetaddress_t *address); +const char *LHNETADDRESS_GetInterfaceName(const lhnetaddress_t *address); int LHNETADDRESS_GetPort(const lhnetaddress_t *address); int LHNETADDRESS_SetPort(lhnetaddress_t *address, int port); int LHNETADDRESS_Compare(const lhnetaddress_t *address1, const lhnetaddress_t *address2);