-// Written by Forest Hale 2003-06-15 and placed into public domain.
+// Written by Ashley Rose Hale (LadyHavoc) 2003-06-15 and placed into public domain.
#ifndef LHNET_H
#define LHNET_H
-#define LHNETADDRESSTYPE_NONE 0
-#define LHNETADDRESSTYPE_LOOP 1
-#define LHNETADDRESSTYPE_INET4 2
-#define LHNETADDRESSTYPE_INET6 3
+typedef enum lhnetaddresstype_e
+{
+ LHNETADDRESSTYPE_NONE,
+ LHNETADDRESSTYPE_LOOP,
+ LHNETADDRESSTYPE_INET4,
+ LHNETADDRESSTYPE_INET6
+}
+lhnetaddresstype_t;
typedef struct lhnetaddress_s
{
- int addresstype;
+ 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, char *ifname, size_t ifnamelength);
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);
void LHNET_Init(void);
void LHNET_Shutdown(void);
+int LHNET_DefaultDSCP(int dscp); // < 0: query; >= 0: set (returns previous value)
void LHNET_SleepUntilPacket_Microseconds(int microseconds);
lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address);
void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket);