typedef struct lhnetaddressnative_s
{
- int addresstype;
+ lhnetaddresstype_t addresstype;
int port;
union
{
namecache[MAX_NAMECACHE];
static int namecacheposition = 0;
-int LHNETADDRESS_FromPort(lhnetaddress_t *vaddress, int addresstype, int port)
+int LHNETADDRESS_FromPort(lhnetaddress_t *vaddress, lhnetaddresstype_t addresstype, int port)
{
lhnetaddressnative_t *address = (lhnetaddressnative_t *)vaddress;
if (!address)
return 0;
switch(addresstype)
{
+ default:
+ return 0;
case LHNETADDRESSTYPE_LOOP:
// local:port (loopback)
memset(address, 0, sizeof(*address));
#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);