aboutsummaryrefslogtreecommitdiffhomepage
path: root/unix.c
diff options
context:
space:
mode:
authorLee Salzman <[email protected]>2017-05-06 14:55:03 -0400
committerLee Salzman <[email protected]>2017-05-06 14:55:03 -0400
commit3ae5af4548d4d0fbf9335f415d14897ce231a5a1 (patch)
treef998314a5e7d1388718d8d120a7e42f52b12cfdf /unix.c
parentf46fee0acc8e243b2b6910b09693f93c3aad775f (diff)
downloadenet-3ae5af4548d4d0fbf9335f415d14897ce231a5a1.tar.gz
enet-3ae5af4548d4d0fbf9335f415d14897ce231a5a1.zip
add portable enet_address_set_host_ip that can properly parse broadcast address
Diffstat (limited to 'unix.c')
-rw-r--r--unix.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/unix.c b/unix.c
index b3cadd0..c36a082 100644
--- a/unix.c
+++ b/unix.c
@@ -102,6 +102,19 @@ enet_time_set (enet_uint32 newTimeBase)
}
int
+enet_address_set_host_ip (ENetAddress * address, const char * name)
+{
+#ifdef HAS_INET_PTON
+ if (! inet_pton (AF_INET, name, & address -> host))
+#else
+ if (! inet_aton (name, (struct in_addr *) & address -> host))
+#endif
+ return -1;
+
+ return 0;
+}
+
+int
enet_address_set_host (ENetAddress * address, const char * name)
{
#ifdef HAS_GETADDRINFO
@@ -153,14 +166,7 @@ enet_address_set_host (ENetAddress * address, const char * name)
}
#endif
-#ifdef HAS_INET_PTON
- if (! inet_pton (AF_INET, name, & address -> host))
-#else
- if (! inet_aton (name, (struct in_addr *) & address -> host))
-#endif
- return -1;
-
- return 0;
+ return enet_address_set_host_ip (address, name);
}
int