Keep in mind this is for BasilsikII 0.8 .....
Code: Select all
Binary files BasiliskII-0.8/BasiliskII and BasiliskII-0.8-pcap/BasiliskII differ
diff -ruN BasiliskII-0.8/src/Unix/configure BasiliskII-0.8-pcap/src/Unix/configu
re
--- BasiliskII-0.8/src/Unix/configure 1999-11-04 05:04:14.000000000 +0800
+++ BasiliskII-0.8-pcap/src/Unix/configure 2014-10-01 09:22:58.000000000 +0
800
@@ -2139,6 +2139,8 @@
fi
+no_x="xno"
+
if [ "x$no_x" = "xyes" ]; then
{ echo "configure: error: You need X11 to run Basilisk II." 1>&2; exit 1; }
fi
@@ -2187,7 +2189,8 @@
#define $ac_tr_lib 1
EOF
- LIBS="-lpthread $LIBS"
+#snealily we add pcap in here too......
+ LIBS="-lpthread -lpcap $LIBS"
else
echo "$ac_t""no" 1>&6
@@ -2281,10 +2284,13 @@
LIBS="-lPTL $LIBS"
+ac_t="yes"
+
else
echo "$ac_t""no" 1>&6
- { echo "configure: error: You need pthreads to run Basilisk II." 1>&2; ex
it 1; }
+# hhh{ echo "configure: error: You need pthreads to run Basilisk II." 1>&2
; exit 1; }
+ { echo "configure: error: You need pthreads to run Basilisk II." 1>&2; }
fi
diff -ruN BasiliskII-0.8/src/Unix/Linux/ether_linux.cpp BasiliskII-0.8-pcap/src/
Unix/Linux/ether_linux.cpp
--- BasiliskII-0.8/src/Unix/Linux/ether_linux.cpp 1999-11-03 18:56:31.0000
00000 +0800
+++ BasiliskII-0.8-pcap/src/Unix/Linux/ether_linux.cpp 2014-09-29 23:41:58.0000
00000 +0800
@@ -26,6 +26,12 @@
#include <errno.h>
#include <stdio.h>
+#include <pcap.h>
+pcap_t *pcap;
+const unsigned char *data;
+struct pcap_pkthdr h;
+
+
#include "cpu_emulation.h"
#include "main.h"
#include "macos_util.h"
@@ -115,15 +121,33 @@
return;
// Is it Ethertap?
- is_ethertap = (strncmp(name, "tap", 3) == 0);
+ is_ethertap = (strncmp(name, "eth", 3) == 0);
// Open sheep_net or ethertap device
char dev_name[16];
+ char errbuf[PCAP_ERRBUF_SIZE];
if (is_ethertap)
+ {
+ memset(errbuf,0,sizeof(errbuf));
+ if((pcap=pcap_open_live(name,1518,1,0,errbuf))==0)
+ {printf("ethernet.c: pcap_open_live error on %s!\n",name
+);exit(-1);}
+// Make pcap nonblocking
+// Normally you would want this, but because of how
+// the threads work and using pcap directly
+// it works better if it doesn't block
+// if (pcap_setnonblock(pcap,1,errbuf))
+// {printf("Error going into nonblocking.\n[%s]\n", errbuf);
+// exit(-1);}
+ }
+ fd=pcap_get_selectable_fd(pcap);
+
+/* if (is_ethertap)
sprintf(dev_name, "/dev/%s", name);
else
strcpy(dev_name, "/dev/sheep_net");
fd = open(dev_name, O_RDWR);
+*/
if (fd < 0) {
sprintf(str, GetString(STR_NO_SHEEP_NET_DRIVER_WARN), dev_name,
strerror(errno));
WarningAlert(str);
@@ -138,7 +162,7 @@
}
// Set nonblocking I/O
- ioctl(fd, FIONBIO, &nonblock);
+ //ioctl(fd, FIONBIO, &nonblock);
// Get Ethernet address
if (is_ethertap) {
@@ -149,6 +173,7 @@
ether_addr[3] = p >> 16;
ether_addr[4] = p >> 8;
ether_addr[5] = p;
+ printf("Ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0]
, ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]);
} else
ioctl(fd, SIOCGIFADDR, ether_addr);
D(bug("Ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0],
ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
@@ -231,13 +256,14 @@
int16 ether_add_multicast(uint32 pb)
{
- if (ioctl(fd, SIOCADDMULTI, Mac2HostAddr(pb + eMultiAddr)) < 0) {
+/* if (ioctl(fd, SIOCADDMULTI, Mac2HostAddr(pb + eMultiAddr)) < 0) {
D(bug("WARNING: Couldn't enable multicast address\n"));
if (is_ethertap)
return noErr;
else
return eMultiErr;
} else
+*/
return noErr;
}
@@ -248,10 +274,11 @@
int16 ether_del_multicast(uint32 pb)
{
- if (ioctl(fd, SIOCDELMULTI, Mac2HostAddr(pb + eMultiAddr)) < 0) {
+/* if (ioctl(fd, SIOCDELMULTI, Mac2HostAddr(pb + eMultiAddr)) < 0) {
D(bug("WARNING: Couldn't disable multicast address\n"));
return eMultiErr;
} else
+*/
return noErr;
}
@@ -319,11 +346,13 @@
// Copy packet to buffer
uint8 packet[1516], *p = packet;
int len = 0;
+/*****
if (is_ethertap) {
*p++ = 0; // Ethertap discards the first 2 bytes
*p++ = 0;
len += 2;
}
+*****/
for (;;) {
int w = ReadMacInt16(wds);
if (w == 0)
@@ -343,9 +372,14 @@
#endif
// Transmit packet
+ if (pcap_sendpacket(pcap, packet, len) < 0) {
+ printf("WARNING: Couldn't transmit packet\n");
+ return excessCollsns;
+/*
if (write(fd, packet, len) < 0) {
D(bug("WARNING: Couldn't transmit packet\n"));
return excessCollsns;
+*/
} else
return noErr;
}
@@ -358,12 +392,13 @@
static void *receive_func(void *arg)
{
for (;;) {
-
- // Wait for packets to arrive
- struct pollfd pf = {fd, POLLIN, 0};
- int res = poll(&pf, 1, -1);
- if (res <= 0)
- break;
+ data=pcap_next(pcap,&h);
+ if(data)
+ {
+ if((memcmp(data+6,ether_addr,6))==0)
+ {}
+ else
+ {
// Trigger Ethernet interrupt
D(bug(" packet received, triggering Ethernet interrupt\n"));
@@ -372,7 +407,9 @@
// Wait for interrupt acknowledge by EtherInterrupt()
sem_wait(&int_ack);
+ }
}
+ }//end for
return NULL;
}
@@ -387,10 +424,14 @@
// Call protocol handler for received packets
uint8 packet[1516];
- for (;;) {
+ //for (;;) { //why do we loop like crazy, once is enough
+ for (int i=0;i<1;i++) {
// Read packet from sheep_net device
- ssize_t length = read(fd, packet, is_ethertap ? 1516 : 1514);
+ //ssize_t length = read(fd, packet, is_ethertap ? 1516 : 1514);
+ ssize_t length = h.caplen;
+ memset(packet,0x0,sizeof(packet));
+ memcpy(packet,data,length);
if (length < 14)
break;
@@ -404,16 +445,22 @@
// Pointer to packet data (Ethernet header)
uint8 *p = packet;
+/*****
if (is_ethertap) {
p += 2; // Ethertap has two random bytes
before the packet
length -= 2;
}
+*****/
// Get packet type
uint16 type = ntohs(*(uint16 *)(p + 12));
// Look for protocol
NetProtocol *prot = find_protocol(type);
+/*
+ if((prot==NULL) || (prot->handler==0))
+ printf("whoops!\n");
+*/
if (prot == NULL)
continue;
@@ -434,9 +481,10 @@
r.a[4] = ether_data + ed_ReadPacket; // Point
er to ReadPacket/ReadRest routines
D(bug(" calling protocol handler %08lx, type %08lx, length %08lx
, data %08lx, rha %08lx, read_packet %08lx\n", prot->handler, r.d[0], r.d[1], r.
a[0], r.a[3], r.a[4]));
Execute68k(prot->handler, &r);
- }
+ }
// Acknowledge interrupt to reception thread
D(bug(" EtherIRQ done\n"));
+ ClearInterruptFlag(INTFLAG_ETHER); //Do we have to?
sem_post(&int_ack);
}
diff -ruN BasiliskII-0.8/src/Unix/sys_unix.cpp BasiliskII-0.8-pcap/src/Unix/sys_
unix.cpp
--- BasiliskII-0.8/src/Unix/sys_unix.cpp 1999-11-01 07:18:37.000000000 +0
800
+++ BasiliskII-0.8-pcap/src/Unix/sys_unix.cpp 2014-09-16 11:56:10.000000000 +0
800
@@ -31,10 +31,14 @@
#include <linux/major.h>
#include <linux/kdev_t.h>
#include <linux/unistd.h>
+#include <values.h> //for MAX_INT
-#ifdef __NR__llseek
+#ifdef __NR__llseek___NOTGOINGTOHAPPEN
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh
);
+#error
#else
+#include <sys/types.h>
+#include <sys/unistd.h>
static int _llseek(uint fd, ulong hi, ulong lo, loff_t *res, uint wh)
{
if (hi)
@@ -120,8 +124,9 @@
void SysAddFloppyPrefs(void)
{
#if defined(__linux__)
- PrefsAddString("floppy", "/dev/fd0H1440");
- PrefsAddString("floppy", "/dev/fd1H1440");
+// PrefsAddString("floppy", "/dev/fd0H1440");
+// PrefsAddString("floppy", "/dev/fd1H1440");
+ PrefsAddString("floppy", "/dev/null");
#elif defined(__NetBSD__)
PrefsAddString("floppy", "/dev/fd0a");
PrefsAddString("floppy", "/dev/fd1a");
Of course I'm looking for ethX since I'm on linux but the better thing would be to add a new statement to look for, and leave the tuntap stuff alone. I'm using generic libpcap calls, not even the 'new style' of dynamically loading... So it's all statically linked. It's interesting that with BasiliskII's threads, it works better in blocking mode.
I should see about adding a tap interface on my macbook, and see if I can get to VM's to see eachother.