I'm now looking at my current version of EDFS if I can somehow prepend the packets with source and destination MAC address when sending (and decoding it when receiving).
That way it can fully use EtherDFS for connecting to various servers using different MAC addresses.
Although in that way, the only thing not sent over the PPP connection is actually a real Ethernet frame, since all other fields would be transmitted (with EDFS Ethertype being forced for the sent packets, no others allowed).
Edit: By handling the insertmacheader (for receiving packets) and sendparams (for sending packets) I've modified it to send the destination (first) and source (second) followed by the packet data (the EtherDFS packet) in both directions.
Essentially, it's sending and receiving full ethernet packets right now, except it's locked down to doing that for EtherDFS packets only (as it's hardlocked to the EtherDFS PPP and Ethernet type and not allowing other types of packets to be sent/received in this driver with the current setup).
The destination and source bytes are taken from the packet data, or put into the packet data when sending/receiving them (in the two functions mentioned above). The normal receive/sending handling handles their endpoints (PPP for sending or buffers/application for receiving) respectively.
I don't know if the output buffer is large enough for 12 extra bytes, though?
Edit: OK. Looked again. It has 14 extra bytes for a possible ethernet header. So no chance of buffer overflow there.
Although the whole thing I made is still untested, it should work in theory. And probably compile as well (assuming I didn't make any typos).
Edit: OK. It didn't compile at first. Needed to iron out some small issues I made in my edits (restoring DNS stuff (still unused because it was zeroed) and a label I removed because of removing encryption support caused said module to fail at other places (restored by placing back the label).
It's comiling now at least (using Make from Turbo C 2.01 with GUI Turbo Assembler 5.1 to compile it (it uses Dosbox for running it))! I also need to delete/rename BUILDINS.MAK within the BIN folder of the app, since make.exe keeps misinterpreting it (and the app recreates it on each time it's started somehow, maybe because it thinks the app is damaged because of the missing file). 😁 Simply running the generated executable makes it seem to run fine, although I don't know how it'll go wrt EDFSCP, since I haven't implemented that one yet in my own emulator. But at least the base executable to connect to a PPP server serving the protocol is implemented now.
Edit: Just implemented the EDFS protocol with that single option into UniPCemu's packet server.
So using that to connect to, it should work, in theory at least (didn't verify it yet).
Edit: OK. Managed to get it to start negotiating the EDFSCP protocol after adjusting the PPP protocol field to 8EF5h and packet channel to EF5h (these were causing issues with protocol field compression, due to the high byte being odd, which needed to be even).
Now the driver seems to send only a 4-byte address field, while it should send a 6-byte address field.
Edit: Fixed the detection of the EDFSCP protocol being up or down, together with having remote and/or local MAC addresses detected correctly (as reported by running EtherDFS).
The only strange thing is that after mounting a disk using EtherDFS, I don't see any packet being sent by the driver over the serial connection?
Edit: Fixed an issue with the packet driver. The stack wasn't cleaned up properly after checking for the special EDFS packet functionality. It should work now, probably.
Edit: Hmmm... Even with those bugfixes, it still crashes somehow?
Running etherdfs 12:34:56:78:9a:bc c-x succeeds in both cases (with esdfsppp correctly listing the local mac when EtherDFS is ran). But with EtherDFS, the whole thing hangs immediately?
Does EtherDFS require a response to work properly? Why won't my modified packet driver send the packets it's supposed to send on to the PPP connection?
Edit: Hmmm... It looks like I've somehow broken the lsppp app with my changes somehow? Can anyone see what's going on?
I run it connecting lsppp or edfspppp to UniPCemu in the same way (with CHAP authentication). I know that the invalid packet types are being blocked by the driver, so that's working properly.
It seems that when the driver tries to send data it somehow goes wrong and ends up hanging the driver? lsppp's original code makes it continue on fine when that happens from what I can see?
Edit: Fixed some bugs in my adjusted code in the EtherDFS PPP driver.
It seems to run now, without crashing at least. The main issues were:
- Moving data back in the source buffer for parsing the extra EDFS packet headers in the data portion of the Ethernet frame (moving the headers sent by the packet server into the received MAC fields expected) to properly save and restore ES for the REP MOVSB instruction to move the data block (instead of using a different ES segment).
- When the EDFSCP layer comes up, properly call vjinit again to initialize the required subsystem (even though it isn't made active due to the define disabling encryption).
(and after that fix the invalid DNS flag I accidentally restored in that commit, which isn't used anymore with the new EDFSCP protocol).
Although the ipup.bat file still reports only the first 4 bytes of the MAC addresses (of the client and server(if provided in the packet server settings)) instead of all 6 bytes of the MAC address.
But luckily, the normal drivers can request those two fields in binary format using the normal driver interface(for the client MAC address, if obtained from the EDFSCP negotiation) or using the special ARP handling (which will result in the server reporting the MAC address results for the EDFS protocol type of any request with the MAC address of the server. This ARP response will only happen if the connecting server identifies itself with it's MAC address (in the documented ARP reply packet way, but with 6 byte protocol addresses instead of IPv4's normal 4 byte protocol addresses) during negotiation (if it isn't provided, ARP EDFS protcol responses are disabled)).
Maybe I'll fix that one later, but for now the driver runs properly from what I can see. Didn't test it actually sending EDFS packets to the server, though. It should send them, according from what I understand from the source code.
Edit: Hmmm... epb_send_pkt in PKT.ASM is for sending a packet for a driver. it calls interfaceup(carry returned for down) to check if the interface is up. Then it makes DS:SI point to the buffer by the app and CX to the amount of bytes in the packet. It calls sendparams to queue it for sending (if it can) and then calls StartXmit to transmit the packet if needed (if sendparams didn't set the carry flag). Othewise, it reports it can't send the packet to the calling application.
I modified bootp_handler not to intercept, so it should progress to vjcompress. vjcompress also clears carry and returns always in my modification. It should reach startXmit(PPP.asm) if it's called.
Edit: OK. Just double-checked the EtherDFS source code. It should be using the normal interfaces (AX=201h for init, 6xx for getaddr, 3xx for free and 4xx for sending). It's init call should register a receive handler (currently nothing is received?), while the send function should be handled by the driver afaik. And if init fails, it would report it. So it should be calling the function?
Edit: Also added a bit of extra functionality. I've extended the 'IP addresses' to 6 numbers for full MAC address coverage. Then added two more options: give the remote a MAC address (assign it one) or (if not given) take their MAC address (otherwise, disable and reject it). Those two options can disable the other side from taking an address (saying it has none) or give it an address as specified. That way, it can even link up to another instance of itself. If the remote doesn't have a MAC address (by not giving it one), the remote address functionality (using ARP) is also disabled, just as if the remote didn't request itself an address.
The generated file with the local and remote addresses isn't adjusted yet, though.
Edit: That's adjusted as well now. It now logs 6 digit addresses (although still in IP dot-seperated decimal format).
Edit: Started implementing an answer dialing mode, but it's crashing right now.
Edit: Fixed the answer mode. Also fixed no-authentication mode and logging without addresses available (due to being rejected or not provided by the server).
Edit: Hmmm... After a lot of bugfixing and improvements, all seems to be working, except the EFDSCP layer going up? For some weird reason, it never reaches the opened state, despite negotiation of configure-request and configure-ack in both directions? Double checked the EDFSCP layer (IPCP.ASM) with the LCP layer and it seems to match.
Edit: OK. The issue is in the main function that checks for the used protocol (EDFSCP or IPCP in the original code) if it's ready to receive.
Oddly enough, changing it to wait for the EDFSCP layer to come up will make the driver not respond to the requests from the server or other client?
Edit: OK. This is getting way too long. I'm moving this to another thread: PPP EtherDFS driver.