Einstein icon indicating copy to clipboard operation
Einstein copied to clipboard

Inbound TCP/IP support

Open mwvaughn opened this issue 3 years ago • 11 comments

Basic Information

  • Platform (Mac, iOS, Android, Linux, etc): Mac
  • Built from source? (yes/no): No
    • If yes, source branch/revision ID:
    • If no, release version: 2020.4.1

Description of issue

I've managed to get the PCMCIA networking stack running for accessing the Internet from my emulated Newton, but I am unable to access services running on the Newton from my localhost. Specifically, I am trying to get an NPDS server running under Einstein. Specifically, I get a connection refused error when I try to access my Newton's nascent HTTP server.

Expected behaviour

I am able to visit http://localhost:8080 (which is what I have the NPDS server configured to use) and receive a response.

Steps to reproduce issue

  1. Install network packages
  2. Configure Internet to use host IP, mask, and DNS with PCMCIA Ethernet Card
  3. Install NPDS and configure it to use port 8080
  4. Start the NPDS server
  5. Visit http://localhost:8080 in a browser

mwvaughn avatar Mar 12 '21 16:03 mwvaughn

The current version has no inbound TCP/IP support. Sorry.

MatthiasWM avatar Mar 12 '21 16:03 MatthiasWM

Thanks, Matthias. I'm one of the original NPDS devs and I was hoping (against all odds) for a miracle on this front!

mwvaughn avatar Mar 12 '21 16:03 mwvaughn

I'll check if it is possible to implement this. No promises ;-)

MatthiasWM avatar Mar 12 '21 18:03 MatthiasWM

Hello @mwvaughn! I think at some point I tried and got something to work, maybe when I worked on SSL. I'll have a look now that @MatthiasWM has merged his work into the master branch.

pguyot avatar Mar 15 '21 07:03 pguyot

Awesome! I am happy to test any time.

mwvaughn avatar Mar 15 '21 16:03 mwvaughn

I confirm it does work, using documentation from 2010 and some help from an article about getting similar results with qemu :-)

Screenshot 2021-03-15 at 22 50 08

To get this working in 2021 on an Intel mac running BigSur, I had to:

  1. Install tap & tun kernel extensions, notarized, from https://github.com/Tunnelblick/Tunnelblick/tree/master/third_party (this is the bit that wouldn't work on M1 Mac, I guess)
  • Copied .kext to /Library/Extensions
  • Fixed them with chown -R 0:0
  • Loaded them with
cd /Library/Extensions/
sudo kextload tap-notarized.kext
  • Restarted, gave permissions in System preferences.

  • Loaded them again with

cd /Library/Extensions/
sudo kextload tap-notarized.kext
  1. Fix permissions as per 2010 doc:
sudo chmod ugo+rw /dev/tap0
  1. Create a bridge interface:
sudo ifconfig bridge1 create
sudo ifconfig bridge1 192.168.100.1/24
sudo ifconfig bridge1 addm en0
  1. Configure pf (instead of ipfw in 2010):
echo "nat on en0 from bridge1:network to any -> (en0)" > pf-config
sudo pfctl -F all
sudo pfctl -f pf-config 
  1. Configure and start the DHCP server Create /etc/bootpd.list with:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>bootp_enabled</key>
        <false/>
        <key>dhcp_enabled</key>
        <array>
            <string>bridge1</string>
        </array>
        <key>netboot_enabled</key>
        <false/>
        <key>relay_enabled</key>
        <false/>
        <key>Subnets</key>
        <array>
            <dict>
                <key>name</key>
                <string>VM NAT Network (192.168.100.0/24)</string>
                <key>net_mask</key>
                <string>255.255.255.0</string>
                <key>net_address</key>
                <string>192.168.100.0</string>
                <key>net_range</key>
                <array>
                    <string>192.168.100.2</string>
                    <string>192.168.100.254</string>
                </array>
                <key>allocate</key>
                <true/>
                <key>dhcp_router</key>
                <string>192.168.100.1</string>
                <key>dhcp_domain_name_server</key>
                <array>
                    <string>8.8.8.8</string>
                </array>
            </dict>
        </array>
    </dict>
</plist>

Start the server in foreground with:

sudo /usr/libexec/bootpd -D -d
  1. Start Einstein (master branch, after Steve's latest commit)
  2. Select the TAP Network driver
  3. Configure the other end of the bridge interface with:
sudo ifconfig bridge1 addm tap0
  1. Install the 5 Internet packages on Einstein, configure Internet connection, experience a bug with the PCMCIA network card producing a -48807. Install NPDS package as well as GIF Server.

  2. Connect with Safari on the IP address provided by the DHCP server (192.168.1.20).

Now, we can keep this ticket open for a long-term goal that would be to get Internet servers available in user-mode networking. Something emulators usually perform by defining a port mapping (you tell the emulator to listen on port X and forward to port Y to the guest).

pguyot avatar Mar 15 '21 22:03 pguyot

On 3/15/2021 11:07 PM, Paul Guyot wrote:

I confirm it does work, using documentation from 2010 https://github.com/pguyot/Einstein/blob/master/Emulator/Network/TTapNetwork.h#L37 and some help from an article https://rambling-ideas.salessandri.name/setup-nat-network-for-qemu-in-mac-osx/ about getting similar results with qemu :-)

Oh wonderful! Yes, the Tap approach has some real advantages. I am glad that my merge did not accidentally trample any of your code and it still works.

  • Matthias

MatthiasWM avatar Mar 15 '21 23:03 MatthiasWM

On 15 Mar 2021, at 23:23, Matthias Melcher @.***> wrote:

On 3/15/2021 11:07 PM, Paul Guyot wrote:

I confirm it does work, using documentation from 2010 https://github.com/pguyot/Einstein/blob/master/Emulator/Network/TTapNetwork.h#L37 and some help from an article https://rambling-ideas.salessandri.name/setup-nat-network-for-qemu-in-mac-osx/ about getting similar results with qemu :-)

Oh wonderful! Yes, the Tap approach has some real advantages. I am glad that my merge did not accidentally trample any of your code and it still works.

  • Matthias

So, will be possible to make NPDS fully working on Einstein?

If ‘yes’ then I do not have words to describe your genius, guys! :)

Cheers, Pawel

INDIGI-CO-UK avatar Mar 16 '21 00:03 INDIGI-CO-UK

Yes, it does work, and it probably has been working since 2010.

pguyot avatar Mar 16 '21 06:03 pguyot

What is the current state of this ticket? Do I still need to do that 'magic' things from Paul's post in MacOS to make NPDS work 'both ways' or is it now implemented in the new version of Einstein?

INDIGI-CO-UK avatar Feb 04 '22 14:02 INDIGI-CO-UK

Incoming TCP connections work on what I can the "native" or "cocoa" version of Einstein on macOS. It does require installing all the drivers that Paul listed up here.

I will leave this open until I have a chance to copy Paul's comments somewhere into the documentation.

The FLTK version of Einstein will not honour incoming requests, and there is no plan to implement it.

MatthiasWM avatar Feb 04 '22 15:02 MatthiasWM