Lorenzo DellacĂ
a39053c3c3
* origin/master: (98 commits) rosalina: fix for latest libctru changes pm: fix critical bugs where 1.0(?) titles not in the list have scheduling mode misconfigured loader: revert to use the NS patch due to a Nintendo bug: https://www.3dbrew.org/wiki/NCCH/Extended_Header#Flag1 loader: replace NS N3DS CPU patch with exheader override, fix overriding exheader with homebrew rosalina: ntp: use PTMSYSM_SetRtcTime revert the memory map to the old one (mostly) fix module loading kext: fix outer memory cacheability on newer versions so bascially rosalina's image... rosalina: add hidden debug info menu rosalina: refactor menu handling rosalina: rephrase brightness warning rosalina: add brightness control menu rosalina/pm: remove fs patch, use pm instead rosalina: cleanup variable names rosalina: reorder menus Fix latest commit rosalina menu: add scrolling, cpad and inputredir support (note: no ZL/ZR due to technical reasons) stuff newlib... ... # Conflicts: # k11_extension/source/main.c # k11_extension/source/svc/UnmapProcessMemoryEx.c # sysmodules/rosalina/Makefile # sysmodules/rosalina/include/menu.h # sysmodules/rosalina/include/utils.h # sysmodules/rosalina/source/errdisp.c # sysmodules/rosalina/source/main.c # sysmodules/rosalina/source/menu.c # sysmodules/rosalina/source/menus.c
81 lines
1.8 KiB
C
81 lines
1.8 KiB
C
/*
|
|
* This file is part of Luma3DS.
|
|
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
|
|
*
|
|
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
|
|
*/
|
|
|
|
/* File mainly written by Stary */
|
|
|
|
#pragma once
|
|
#include <3ds/types.h>
|
|
#include <poll.h>
|
|
#include <netinet/in.h>
|
|
|
|
#define MAX_PORTS (3+1)
|
|
#define MAX_CTXS (2 * MAX_PORTS)
|
|
|
|
struct sock_server;
|
|
struct sock_ctx;
|
|
|
|
typedef int (*sock_accept_cb)(struct sock_ctx *client_ctx);
|
|
typedef int (*sock_data_cb)(struct sock_ctx *client_ctx);
|
|
typedef int (*sock_close_cb)(struct sock_ctx *client_ctx);
|
|
|
|
typedef struct sock_ctx* (*sock_alloc_func)(struct sock_server *serv, u16 port);
|
|
typedef void (*sock_free_func)(struct sock_server *serv, struct sock_ctx *ctx);
|
|
|
|
typedef enum socket_type
|
|
{
|
|
SOCK_NONE,
|
|
SOCK_SERVER,
|
|
SOCK_CLIENT
|
|
} socket_type;
|
|
|
|
typedef struct sock_ctx
|
|
{
|
|
enum socket_type type;
|
|
bool should_close;
|
|
int sockfd;
|
|
struct sockaddr_in addr_in;
|
|
struct sock_ctx *serv;
|
|
int n;
|
|
int i;
|
|
} sock_ctx;
|
|
|
|
typedef struct sock_server
|
|
{
|
|
// params
|
|
u32 host;
|
|
int clients_per_server;
|
|
|
|
// poll stuff
|
|
struct pollfd poll_fds[MAX_CTXS];
|
|
struct sock_ctx serv_ctxs[MAX_PORTS];
|
|
struct sock_ctx *ctx_ptrs[MAX_CTXS];
|
|
|
|
nfds_t nfds;
|
|
bool running;
|
|
Handle started_event;
|
|
bool compact_needed;
|
|
|
|
// callbacks
|
|
sock_accept_cb accept_cb;
|
|
sock_data_cb data_cb;
|
|
sock_close_cb close_cb;
|
|
|
|
sock_alloc_func alloc;
|
|
sock_free_func free;
|
|
|
|
Handle shall_terminate_event;
|
|
Result init_result;
|
|
} sock_server;
|
|
|
|
Result server_init(struct sock_server *serv);
|
|
Result server_bind(struct sock_server *serv, u16 port);
|
|
void server_run(struct sock_server *serv);
|
|
void server_kill_connections(struct sock_server *serv);
|
|
void server_set_should_close_all(struct sock_server *serv);
|
|
void server_finalize(struct sock_server *serv);
|
|
bool Wifi__IsConnected(void);
|