Files
LibretroAdmin c04b91fe69 network: modem V.42 and 56K, the Broadband Adapter, DCNet
The modem:
- V.42 error correction (LAPM) and V.42bis compression for the games
  that dial in sync mode, which were forced to async, and V.8bis and
  56K (V.90/K56 speeds).
- Receive and transmit FIFOs timed by the line's speeds, the TXFNF/TXHF
  status bits, and Power Smash's symmetric speed.
- PPP waits for the game to speak first, on the network thread; this
  replaces the quarter-second delay on reads.
- Its ID reports the country as USA, as upstream's.
- Frames short or long, an XID with bad lengths, a REJ for a frame that
  is gone, a V.8bis message without its end, a V.42bis step-up of a
  dictionary not a power of two: none can read or write past a buffer,
  loop for ever or be refused wrongly any more.

The Broadband Adapter could not be turned on: settings forced it off
and nothing set it. The option "Expansion Port Device (Restart
Required)" (reicast_network_device) chooses the modem, the adapter or
nothing; the modem by default, as before. The adapter gets its
link-change interrupt 10 ms after a reset, as KallistiOS waits for, frames
under 6 or over 1514 bytes are dropped, and the network starts with the
game's first frame and stops on a GAPS reset.

DCNet: "Use DCNet" (reicast_dcnet, off by default) goes online through
the dcnet.flyca.st relay instead of picoTCP, on the same network thread,
non-blocking, without locks. Power Smash and Pro Yakyuu always go
through it, as upstream has them.

picoTCP: dns.flyca.st as the name server; a socket that is ready is read
whole (an upload no longer stalls); the ports of Daytona, Sega Tetris,
Golf Shiyouyo 2, Dee Dee Planet, Driving Strikers, Floigan and the
Internet Game Pack. Stopping the network thread no longer waits for it.

In the save state (V24), on a Dreamcast: the device chosen and what the
modem (FIFOs, V.42, V.42bis, V.8bis) and the adapter (GAPS, its RAM, the
RTL8139) hold, 34 KB. A live connection cannot be in a state: one loaded
replays what came over the line at the times it came, and a line the
state does not have hangs up, without waiting for the thread.

tools/threads/pico_test.cpp tests the thread with the new interface,
and DCNet against a stand-in relay.
2026-10-13 14:37:55 +02:00

49 lines
2.2 KiB
C

/*
This file is part of Flycast.
Flycast is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Flycast is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "types.h"
#include "net_platform.h"
/* The network thread's side of what it shares with the emulation thread
* (picoppp.cpp): rings that take no lock, one writer and one reader each,
* and a socket the emulation thread wakes it with. For what runs on that
* thread: picoTCP, or DCNet. */
// False once the thread is to stop
bool netthread_running();
// To be read before looking for work, and given to netthread_wait()
int netthread_kicks();
// The bytes the modem has sent
size_t netthread_modem_take(u8 *buf, size_t len);
/* Bytes for the modem: how many there was room for. When there was not
* room for all, the thread is woken once the modem has read some. */
size_t netthread_modem_give(const u8 *buf, size_t len);
// The next frame the adapter has sent, into @frame (NET_ETH_FRAME_MAX bytes): its size, 0 for none
u32 netthread_eth_take(u8 *frame);
/* A frame for the adapter. False if there is no room for it: the thread is
* woken once the adapter has taken some. */
bool netthread_eth_give(const u8 *frame, u32 size);
/* Waits for one of the sockets in @readable or @writable, for something
* from the emulation thread, or for @timeout_ms. @kicks: netthread_kicks()
* from before the thread last looked for work. */
void netthread_wait(int kicks, fd_set *readable, fd_set *writable, int max_fd, int timeout_ms);
// The IPv4 address of @host (network order), 0 if it has none
u32 netthread_resolve(const char *host);
// DCNet, in place of the stack (dcnet.cpp)
void dcnet_run(bool bba);