summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/addrinfo.h5
-rw-r--r--ext/socket/extconf.rb2
-rw-r--r--ext/socket/getaddrinfo.c12
-rw-r--r--ext/socket/getnameinfo.c12
-rw-r--r--ext/socket/socket.c6
-rw-r--r--ext/socket/sockport.h24
6 files changed, 53 insertions, 8 deletions
diff --git a/ext/socket/addrinfo.h b/ext/socket/addrinfo.h
index 74fae207b9..6000a466ba 100644
--- a/ext/socket/addrinfo.h
+++ b/ext/socket/addrinfo.h
@@ -127,11 +127,6 @@
#define NI_NUMERICSERV 0x00000008
#define NI_DGRAM 0x00000010
-#ifdef NT
-#define IN_EXPERIMENTAL(x) 0
-#define IN_LOOPBACKNET 0
-#endif
-
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
int ai_family; /* PF_xxx */
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index b0b44180c9..d1ce000f5e 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -306,6 +306,8 @@ else
$objs += ["getnameinfo.#{$OBJEXT}"]
have_func("inet_ntop") or have_func("inet_ntoa")
have_func("inet_pton") or have_func("inet_aton")
+ have_func("getservbyport")
+ have_header("arpa/inet.h")
have_header("arpa/nameser.h")
have_header("resolv.h")
end
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index c312b92705..d518017bc8 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -42,9 +42,15 @@
#include <sys/types.h>
#ifndef NT
#include <sys/param.h>
-#include <sys/socket.h>
+#if defined(__BEOS__)
+# include <net/socket.h>
+#else
+# include <sys/socket.h>
+#endif
#include <netinet/in.h>
+#if defined(HAVE_ARPA_INET_H)
#include <arpa/inet.h>
+#endif
#if defined(HAVE_ARPA_NAMESER_H)
#include <arpa/nameser.h>
#endif
@@ -330,12 +336,16 @@ getaddrinfo(hostname, servname, hints, res)
pai->ai_socktype = SOCK_STREAM;
break;
default:
+#if defined(SOCK_RAW)
pai->ai_socktype = SOCK_RAW;
+#endif
break;
}
break;
+#if defined(SOCK_RAW)
case SOCK_RAW:
break;
+#endif
case SOCK_DGRAM:
if (pai->ai_protocol != IPPROTO_UDP &&
pai->ai_protocol != ANY)
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index 60bd71bac6..bd3bd129bf 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -37,9 +37,15 @@
#include "config.h"
#include <sys/types.h>
#ifndef NT
-#include <sys/socket.h>
+#if defined(__BEOS__)
+# include <net/socket.h>
+#else
+# include <sys/socket.h>
+#endif
#include <netinet/in.h>
+#if defined(HAVE_ARPA_INET_H)
#include <arpa/inet.h>
+#endif
#if defined(HAVE_ARPA_NAMESER_H)
#include <arpa/nameser.h>
#endif
@@ -178,6 +184,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
return ENI_MEMORY;
strcpy(serv, numserv);
} else {
+#if defined(HAVE_GETSERVBYPORT)
sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
if (sp) {
if (strlen(sp->s_name) > servlen)
@@ -185,6 +192,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
strcpy(serv, sp->s_name);
} else
return ENI_NOSERVNAME;
+#else
+ return ENI_NOSERVNAME;
+#endif
}
switch (sa->sa_family) {
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 8cf8f8d37f..c65de566e4 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -21,7 +21,11 @@
#endif
#ifndef NT
-#include <sys/socket.h>
+#if defined(__BEOS__)
+# include <net/socket.h>
+#else
+# include <sys/socket.h>
+#endif
#include <netinet/in.h>
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
diff --git a/ext/socket/sockport.h b/ext/socket/sockport.h
index e3750816c6..d19b1e1dba 100644
--- a/ext/socket/sockport.h
+++ b/ext/socket/sockport.h
@@ -45,4 +45,28 @@
# define IN_MULTICAST(i) IN_CLASSD(i)
#endif
+#ifndef IN_EXPERIMENTAL
+# define IN_EXPERIMENTAL(i) ((((long)(i)) & 0xe0000000) == 0xe0000000)
+#endif
+
+#ifndef IN_CLASSA_NSHIFT
+# define IN_CLASSA_NSHIFT 24
+#endif
+
+#ifndef IN_LOOPBACKNET
+# define IN_LOOPBACKNET 127
+#endif
+
+#ifndef AF_UNSPEC
+# define AF_UNSPEC 0
+#endif
+
+#ifndef PF_UNSPEC
+# define PF_UNSPEC AF_UNSPEC
+#endif
+
+#ifndef PF_INET
+# define PF_INET AF_INET
+#endif
+
#endif