98 lines
2.4 KiB
C
98 lines
2.4 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "error/error.h"
|
|
#include "network/networkinfo.h"
|
|
#include <network.h>
|
|
|
|
#define NETWORK_DOLPHIN_IP_MAX 16
|
|
|
|
#ifdef DUSK_GAMECUBE
|
|
// No DNS client is implemented for GameCube yet (see
|
|
// networkSocketDolphinConnect) -- only literal IP addresses work.
|
|
// A future resolver should query this server.
|
|
#ifndef NETWORK_DOLPHIN_DNS_SERVER_IP
|
|
#define NETWORK_DOLPHIN_DNS_SERVER_IP "0.0.0.0"
|
|
#endif
|
|
#endif
|
|
|
|
typedef struct {
|
|
char_t ip[NETWORK_DOLPHIN_IP_MAX];
|
|
char_t netmask[NETWORK_DOLPHIN_IP_MAX];
|
|
char_t gateway[NETWORK_DOLPHIN_IP_MAX];
|
|
|
|
void *onConnectedUser;
|
|
void (*onConnected)(void *user);
|
|
void (*onFailed)(errorret_t error, void *user);
|
|
} networkdolphin_t;
|
|
|
|
/**
|
|
* Initializes the network stack (IOS on Wii, bundled lwIP + BBA driver on
|
|
* GameCube). Does not connect; use networkDolphinRequestConnection for
|
|
* that.
|
|
*
|
|
* @return Error state (if any).
|
|
*/
|
|
errorret_t networkDolphinInit();
|
|
|
|
/**
|
|
* Called each frame. No-op since connection is synchronous.
|
|
*
|
|
* @return Error state (if any).
|
|
*/
|
|
errorret_t networkDolphinUpdate();
|
|
|
|
/**
|
|
* Disposes the network stack.
|
|
*
|
|
* @return Error state (if any).
|
|
*/
|
|
errorret_t networkDolphinDispose();
|
|
|
|
/**
|
|
* Returns true if connected to a network.
|
|
*
|
|
* @return True if connected.
|
|
*/
|
|
bool_t networkDolphinIsConnected();
|
|
|
|
/**
|
|
* Requests a connection to the network: the Wi-Fi settings saved in the
|
|
* Wii System Menu on Wii, or DHCP over the Broadband Adapter on GameCube.
|
|
* Blocks until connected or failed.
|
|
*
|
|
* @param onConnected Callback on successful connection.
|
|
* @param onFailed Callback if connection fails.
|
|
* @param onDisconnect Callback when connection is later lost.
|
|
* @param user User data passed to all callbacks.
|
|
*/
|
|
void networkDolphinRequestConnection(
|
|
void (*onConnected)(void *user),
|
|
void (*onFailed)(errorret_t error, void *user),
|
|
void (*onDisconnect)(errorret_t error, void *user),
|
|
void *user
|
|
);
|
|
|
|
/**
|
|
* Requests to disconnect from the network.
|
|
*
|
|
* @param onComplete Callback when disconnection is complete.
|
|
* @param user User data passed to the callback.
|
|
*/
|
|
void networkDolphinRequestDisconnection(
|
|
void (*onComplete)(void *user),
|
|
void *user
|
|
);
|
|
|
|
/**
|
|
* Returns the current network IP information.
|
|
*
|
|
* @return Network info for the active connection.
|
|
*/
|
|
networkinfo_t networkDolphinGetInfo();
|