Hi Joel,
those are really good news. I've tried to compile it on mac, and here are the results.
You need to configure openssl for 64bit, otherwise doesn't link: './Configure darwin64-x86_64-cc' instead of './config'
On the makefile, there is a missing '-e' after '-i' for the sed command on line 1444
I had to remove -Werror when compiling android native code, otherwise I get:
cc1plus: warnings being treated as errors
build/darwin-x86_64-android/android-src/libcore_io_Posix.cpp: In function ‘void Posix_setsockoptGroupReq(JNIEnv*, _jobject*, _jobject*, jint, jint, _jobject*)’:
build/darwin-x86_64-android/android-src/libcore_io_Posix.cpp:1177: warning: ‘Posix_setsockoptGroupReq(JNIEnv*, _jobject*, _jobject*, jint, jint, _jobject*)::group_req64’ declared with greater visibility than the type of its field ‘Posix_setsockoptGroupReq(JNIEnv*, _jobject*, _jobject*, jint, jint, _jobject*)::group_req64::gr_group’
make: *** [build/darwin-x86_64-android/libcore_io_Posix.o] Error 1
There were many errors compiling libcore_net_RawSocket.cpp, but I managed to make it compile. I tried my best to find correct replacements without changing much code, but I've never played with sockets in C at this level before, so it's probably wrong. Also, I just modified it to compile on Mac, as I don't know what are the best practices for doing this with defines. I hope at least helps pointing in the right direction. The changes made to libcore_net_RawSocket.cpp at the end of the email.
Finally, during test, Buffers, Misc and Strings failed. I attach the log.
That's all for now, but it looks that porting it to Mac should be easy.
Cheers,
Pablo
############################
@@ -25,20 +25,36 @@
#include "jni.h"
#include <sys/types.h>
#include <sys/socket.h>
-#include <linux/rtnetlink.h>
+//#include <linux/rtnetlink.h>
#include <net/if.h>
-#include <linux/if_ether.h>
-#include <linux/if_packet.h>
+//#include <linux/if_ether.h>
+//#include <linux/if_packet.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <netinet/ip.h>
-#include <linux/udp.h>
+//#include <linux/udp.h>
+#include <netinet/udp.h>
+
+typedef uint16_t __be16;
+
+struct sockaddr_ll {
+ unsigned short sll_family;
+ __be16 sll_protocol;
+ int sll_ifindex;
+ unsigned short sll_hatype;
+ unsigned char sll_pkttype;
+ unsigned char sll_halen;
+ unsigned char sll_addr[8];
+};
+
+#define PF_PACKET AF_INET
+#define AF_PACKET AF_INET
union sockunion {
sockaddr sa;
sockaddr_ll sll;
};
@@ -185,20 +201,20 @@ static jint RawSocket_recvPacket(JNIEnv* env, jclass, jobject fileDescriptor,
}
if (port != -1) {
// quick check for UDP type & UDP port
// the packet is an IP header, UDP header, and UDP payload
- if ((size < (sizeof(struct iphdr) + sizeof(struct udphdr)))) {
+ if ((size < (sizeof(struct ip) + sizeof(struct udphdr)))) {
return 0; // runt packet
}
- u_int8_t ip_proto = ((iphdr *) packetData)->protocol;
+ u_int8_t ip_proto = ((ip *) packetData)->ip_p;
if (ip_proto != IPPROTO_UDP) {
return 0; // something other than UDP
}
- __be16 destPort = htons((reinterpret_cast<udphdr*>(packetData + sizeof(iphdr)))->dest);
+ __be16 destPort = htons((reinterpret_cast<udphdr*>(packetData + sizeof(ip)))->uh_dport);
if (destPort != port) {
return 0; // something other than requested port
}
}
Very impressive!
I don't have much time currently but when the dust settles, I'll test the Scala/REPL stuff on top of it.
--
You received this message because you are subscribed to the Google Groups "Avian" group.
To unsubscribe from this group and stop receiving emails from it, send an email to avian+un...@googlegroups.com.
To post to this group, send email to av...@googlegroups.com.
Visit this group at http://groups.google.com/group/avian?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Avian" group.
To unsubscribe from this group and stop receiving emails from it, send an email to avian+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to avian+un...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Avian" group.
To unsubscribe from this group and stop receiving emails from it, send an email to avian+unsubscribe@googlegroups.com.
To post to this group, send email to av...@googlegroups.com.
Visit this group at http://groups.google.com/group/avian.