summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-10 04:49:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-10 04:49:24 +0000
commitc67a74570dd056569763f5015e0aafa7d454fca7 (patch)
treef1dda39296b6911752cd4b6446a21f2e54ff68e1 /ext/socket
parent3043170b14875ce53f3a951d665279b12c2c63a8 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-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 74fae20..6000a46 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 b0b4418..d1ce000 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 c312b92..d518017 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 60bd71b..bd3bd12 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 8cf8f8d..c65de56 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 e375081..d19b1e1 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