VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

I want to emulate a NE2000 network card using SDL2_net in pure C(no C++ code, since it isn't supported in my project). Is that possible? Are there any tutorials on sending and receiving raw TCP packets using SDL(2)_net?

I see Dosbox using WinPCap, but can SDL(2)_net be used for it instead?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 4, by crazyc

User metadata
Rank Member
Rank
Member

Only if you are tunnelling, sdl_net can't send raw ethernet frames, they're going to have an IP and ethernet header prepended (and probably a TCP or UDP header too as it doesn't seem to do raw IP either). That's why winpcap or slirp is used by emulators (or tun/tap on linux).

Reply 2 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

What about other devices, like the PSP and Android?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 3 of 4, by crazyc

User metadata
Rank Member
Rank
Member

With android pcap and tap may be available but likely only for rooted devices. Although, with pcap i believe, on wireless devices, you'd have to translate your ethernet frames to 802.11 manually. On the psp only slirp would work (unless you want to complete the reverse engineering of the wireless chip and again you'd have to do translation to 802.11).

Reply 4 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

So the safest bet would be to emulate a Modem on a COM port that deals in SLIRP packages, then send those directly on the PSP, while through PCAP(as far as I can see the only one Dosbox supports) after translation on the other devices? Is that correct?

Btw, can SLIP packages be converted directly without modification(by simply adding the higher layers) to use with PCAP/TAP? That way, I can let the virtual modem deal in SLIP packets, while sending them through a common framework which sends it using a higher layer with PCAP/TAP and without translation on the PSP?

An UART modem does deal in SLIP packages, is that correct(dial-up modem)? So simply translate those to either SLIRP or packages for PCAP and I'm good to go?

So let the virtual modem connect to any phonenumber, report it's connected, let the modem be put in data mode and then simple stream out/in the SLIP packages. Those SLIP packages are translated into SLIRP packages or PCAP packages before sending and converted backwards when receiving? The SLIP packages are embedded IP packets after all, so translation to/from the native PCAP/TAP or SLIRP packages should be easy? Would that work for all stuff done in a browser(website lookups etc.)?

Edit: It seems SLIP used by those modems(on the Serial port) deal in TCP/IP packets, which are wrapped in SLIP packets. So simply extracting the data from the SLIP packet, add a IEEE 802.11 packet around it, then send it to the network directly? And the reverse for received packets?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io