[Simh] Networking Via files...

Jason Stevens neozeed at gmail.com
Mon May 7 12:19:44 EDT 2007


I don't know if anyone else will find this even remotely usefull, but I have
this friend that has a very restrictive network.  Their internet usage is
tracked, and the pc's cannot talk site to site.  However there is a common
fileserver in the middle....

So I cooked up this little 'gem'.

This way people in site 'A' can telnet to their vax, likewise with site
'B'.  The network admins won't see irc, ftp, email whatever on the vaxa ->
vaxb link since it's going through the fileserver.  I haven't even profiled
how much bandwidth it uses so you with extreme caution!

I'm using he 11/780 (small memory footprint..) and here is how to initallize
it.  the parameter for the networking is the path in which you need an 'a'
and 'b' directory.  In this case on the V: drive. (Sorry its MS only with
sopen.. I'm sure there is some kind of open exclusive on *nix, but if you
have NFS.....)

set xu ena
set xu MAC=08:00:2B:CC:DD:01
att xu v:\temp\

You will need to build two exe's one compiled with USE_NETA and the other
with USE_NETB.

The following code can be dropped into sim_ether.c , in place of the #ifdef
USE_NETWORK portion.

Again I don't know if anyone will be even remotly interested in this...

 ------8< ------8< ------8< ------8< ------8< ------8< ------8<
------8< ------8< ------8<
#ifdef USE_NETWORK
#include <fcntl.h>               /*constants defined*/
#include <sys\types.h>
#include <sys\stat.h>            /*constants defined*/
#include <share.h>               /*constants defined*/
#include <io.h>

#define USE_NETA
//#define USE_NETB


//Packet couters for reading/writing
int Packet;
int PacketR;
char Path[255];

t_stat eth_open (ETH_DEV* dev, char* name)
  {
    Packet=0;
   PacketR=0;
#ifdef USE_NETA
   printf("the A client");
#endif
#ifdef USE_NETB
   printf("the B client");
#endif
   memset(Path,0x0,sizeof(Path));
   sprintf(Path,"%s",name);
   printf("\t%s\n",Path);
   return SCPE_OK;
  }

t_stat eth_close (ETH_DEV* dev)
  {
 return SCPE_NOFNC;
 }
/************Helper functions...***************************/


void sendpacket(char *p);
/*************************************************************/

t_stat eth_write (ETH_DEV* dev, ETH_PACK* packet, ETH_PCALLBACK routine)
  {
  int status = 1;   /* default to failure */

  /* make sure device exists */
  if (!dev) return SCPE_UNATT;

  /* make sure packet exists */
  if (!packet) return SCPE_ARG;

  /* make sure packet is acceptable length */
  if ((packet->len >= ETH_MIN_PACKET) && (packet->len <= ETH_MAX_PACKET)) {
   char buffer[5000];
   char fname[255];
   FILE *outz;

   memset(buffer,0x0,sizeof(buffer));
   memset(fname,0x0,sizeof(fname));
#ifdef USE_NETA
   sprintf(fname,"%sa\\packet_%d.cap",Path,Packet);
#else
   sprintf(fname,"%sb\\packet_%d.cap",Path,Packet);
#endif

   outz=sopen(fname,O_RDWR | O_BINARY | O_CREAT, SH_DENYRW, S_IREAD |
S_IWRITE);
   eth_add_crc32(packet->msg);
   write(outz,packet->msg,packet->len);
   close(outz);
   status=0;
   Packet++;

    /* detect sending of decnet loopback packet */
    if ((status == 0) && DECNET_SELF_FRAME(dev->decnet_addr, packet->msg))
      dev->decnet_self_sent += dev->reflections;

  } /* if packet->len */

  /* call optional write callback function */
  if (routine)
    (routine)(status);
  return SCPE_OK;
}

/*************************************************************/
t_stat eth_read (ETH_DEV* dev, ETH_PACK* packet, ETH_PCALLBACK routine)
  {

  int status;

  /* make sure device exists */
  if (!dev) return SCPE_UNATT;

  /* make sure packet exists */
  if (!packet) return SCPE_ARG;

  /* set read packet */
  dev->read_packet = packet;
  packet->len = 0;

  /* set optional callback routine */
  dev->read_callback = routine;

  /* dispatch read request to either receive a filtered packet or timeout */
  do {
    char fname[255];
    FILE *inz;
  int j=0;
#ifdef USE_NETA
  sprintf(fname,"%sb\\packet_%d.cap",Path,PacketR);
#endif
#ifdef USE_NETB
  sprintf(fname,"%sa\\packet_%d.cap",Path,PacketR);
#endif
  inz=sopen(fname,O_RDWR | O_BINARY, SH_DENYRW);

 if(inz==-1)
 {
  return SCPE_OK;
 }
 else
 {
  unsigned char packetbuffer[2000];
  memset(packetbuffer,0x0,sizeof(packetbuffer));
  j=read(inz,packetbuffer,sizeof(packetbuffer));
  close(inz);
  unlink(fname);
  dev->read_packet->len=j;
  memcpy(dev->read_packet->msg,packetbuffer,j);
  eth_add_crc32(dev->read_packet);
  if (dev->read_callback)
   (dev->read_callback)(0);
  PacketR++;

 }

  return SCPE_OK;
 } while ((status) && (0 == packet->len));
}


////////////////////////////////////////////////////////////////////////
t_stat eth_filter (ETH_DEV* dev, int addr_count, ETH_MAC* addresses,
                   ETH_BOOL all_multicast, ETH_BOOL promiscuous)
  {return SCPE_NOFNC;}
int eth_devices (int max, ETH_LIST* dev)
  {return 0;}

#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.trailing-edge.com/pipermail/simh/attachments/20070507/630041c9/attachment-0003.html>


More information about the Simh mailing list