<div>I've done some hacking with the networking on qemu & simh, and I've finally done something that's been on my list of things to do.  Qemu has a built in 'user mode networking' stack called slirp that will allow Qemu to connect to the network without any tap/tun or libpcap.  All TCP/IP traffic on the ethernet is intercepted, and operated on the host side.  If you remember slirp from the "good old days" when everyone had shell accounts, then the windows people would build slirp so a stubbed out 
winsock.dll would allow them to use winsock applications going thru the host computer.</div>
<div> </div>
<div>Anyways I've tested this successfully with the VAX emulator.  It appears that there is some weird issues either with the way the vax780 emulator handles it's ethernet card (which may be why it's disabled to start with), or with BSD 
4.3 / Taho on how their ethernet frames are...   Right now I'm testing with IRC on 4.3 BSD Quasijarus UNIX #3.  I've also included a redir port so that I can 'telnet' into the host.  </div>
<div> </div>
<div>I don't know if anyone would even find this interesting, but the prospect of a 'drop and go' host is quite usefull for me at least.  Not to mention it'll be a snap to setup on the network, or install Operating Systems like OpenBSD which can pull the rest of the OS via HTTP.
</div>
<div> </div>
<div>Remember it's best to use the following config under slirp</div>
<div> </div>
<div>Host IP     <a href="http://10.0.2.15">10.0.2.15</a></div>
<div>Netmask   <a href="http://255.255.255.0">255.255.255.0</a></div>
<div>Gateway   <a href="http://10.0.2.2">10.0.2.2</a></div>
<div>DNS         <a href="http://10.0.2.3">10.0.2.3</a></div>
<div> </div>
<div> </div>
<div>In the source below, I've hardcoded port 42323 on the host to go to port 23 on the emulated vax.  I then telnet to the loop on 42323 and connect to the OS.</div>
<div> </div>
<div>If you want to try, download and configure qemu on your PC.  I just then copied the slirp files into simh, and added them to the makefile.  I had to copy some config headers from qemu to satisfy the last of the slirp dependancies.  From what I can gather the major 'block' here is that slirp needs to know what endian the host is at compile time.
</div>
<div> </div>
<div>For what it's worth, here is my addition to the sim_ether file.  I'm sorry it's not a diff, I had removed the os dependant portion from the independant portion to speed my compiles & tests...</div>
<div>
<div>
<p>#include "slirp.h"<br>#include <ctype.h><br>#include "sim_ether.h"<br>#include "sim_sock.h"</p>
<p>unsigned char tbuff[2000];<br>int tbufflen;<br>int slirp_inited=0;<br>extern fd_set *global_readfds, *global_writefds, *global_xfds;</p>
<p>t_stat eth_open(ETH_DEV* dev, char* name, DEVICE* dptr, uint32 dbit)<br>  {<br>        struct in_addr guest_addr;<br>        slirp_init();<br>        tbufflen=0;<br>        slirp_inited=1;<br>        inet_aton("<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://10.0.2.15/" target="_blank">
 10.0.2.15</a>",&guest_addr);<br>        slirp_redir(0,42323,guest_addr,23);<br>        return SCPE_OK;<br>        }</p>
<p>t_stat eth_close (ETH_DEV* dev)<br>  {slirp_exit(1);<br>        return SCPE_OK;}</p>
<p>t_stat eth_write (ETH_DEV* dev, ETH_PACK* packet, ETH_PCALLBACK routine)<br>  {<br>        slirp_input(packet->msg,packet->len);<br>        if(routine)<br>        (routine)(0);<br>        return SCPE_OK;<br>  }</p>

<p> </p>
<p>t_stat eth_read (ETH_DEV* dev, ETH_PACK* packet, ETH_PCALLBACK routine)<br>  {<br>        int ret,nfds;<br>        fd_set rfds, wfds, xfds;<br>        struct timeval tv; </p>
<p>if(!dev) return SCPE_UNATT;<br>if(!packet) return SCPE_ARG;</p>
<p>dev->read_packet = packet;<br>packet->len = 0;<br>dev->read_callback = routine;</p>
<p>if(tbufflen>0)<br>        {<br>        dev->read_packet->len=tbufflen;<br>        memcpy(dev->read_packet->msg,tbuff,tbufflen);<br>        eth_add_crc32(dev->read_packet);<br>        if(dev->read_callback)
<span></span> <br>         (dev->read_callback)(0);<br>        tbufflen=0;<br>        }</p>
<p><br>nfds=-1;<br>FD_ZERO(&rfds);<br>FD_ZERO(&wfds);<br>FD_ZERO(&xfds);<br>if(slirp_inited)<br>        {<br>        slirp_select_fill(&nfds,&rfds,&wfds,&xfds);<br>        tv.tv_sec=0;<br>        
tv.tv_usec=0;<br>        ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);<br>        if(ret>0)<br>                {}<br>        if(ret<0) {<br>            FD_ZERO(&rfds);<br>            FD_ZERO(&wfds); 
<br>            FD_ZERO(&xfds);<br>            }<br>        slirp_select_poll(&rfds, &wfds, &xfds);<br>        }</p>
<p><br>return SCPE_OK;<br>}</p>
<p><br>t_stat eth_filter (ETH_DEV* dev, int addr_count, ETH_MAC* addresses,<br>                   ETH_BOOL all_multicast, ETH_BOOL promiscuous)<br>  {return SCPE_NOFNC;}</p>
<p>int eth_devices (int max, ETH_LIST* dev)<br>  {return -1;}</p>
<p>void slirp_output (const unsigned char *pkt, int pkt_len)<br>{<br>tbufflen=pkt_len;<br>memcpy(tbuff,pkt,pkt_len);<br>}</p>
<p>int slirp_can_output(void)<br>{<br>return 1;<br>}</p>
<p> </p>
<p> </p>
<p> </p>
<p>-------</p>
<p>Let me know if anyone is interested, and I'll check out what the full licensing is involved in this....</p>
<p>Jason Stevens</p></div></div>