Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inital attempt at WiFi support #143

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ HAVE_OPENGL := 0
HAVE_OPENGLES3 := 0
HAVE_THREADS := 0
HAVE_WIFI := 1
HAVE_SLIRP := 0

SPACE :=
SPACE := $(SPACE) $(SPACE)
Expand Down Expand Up @@ -452,6 +453,10 @@ else
HAVE_OPENGL=1
HAVE_THREADS=1

ifeq ($(HAVE_SLIRP), 1)
LDFLAGS += -lglib-2.0
endif

ifeq ($(MSYSTEM),MINGW64)
CC ?= x86_64-w64-mingw32-gcc
CXX ?= x86_64-w64-mingw32-g++
Expand Down
39 changes: 39 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,45 @@ SOURCES_CXX += $(MELON_DIR)/GPU_OpenGL.cpp \
DEFINES += -DHAVE_OPENGL -DOGLRENDERER_ENABLED -DCORE
endif

ifeq ($(HAVE_SLIRP), 1)
SOURCES_CXX += $(MELON_DIR)/frontend/qt_sdl/LAN_Socket.cpp \

# libslirp
SOURCES_C += $(MELON_DIR)/libslirp-v4.6.1/src/arp_table.c \
$(MELON_DIR)/libslirp-v4.6.1/src/bootp.c \
$(MELON_DIR)/libslirp-v4.6.1/src/cksum.c \
$(MELON_DIR)/libslirp-v4.6.1/src/dhcpv6.c \
$(MELON_DIR)/libslirp-v4.6.1/src/dnssearch.c \
$(MELON_DIR)/libslirp-v4.6.1/src/if.c \
$(MELON_DIR)/libslirp-v4.6.1/src/ip6_icmp.c \
$(MELON_DIR)/libslirp-v4.6.1/src/ip6_input.c \
$(MELON_DIR)/libslirp-v4.6.1/src/ip6_output.c \
$(MELON_DIR)/libslirp-v4.6.1/src/ip_icmp.c \
$(MELON_DIR)/libslirp-v4.6.1/src/ip_input.c \
$(MELON_DIR)/libslirp-v4.6.1/src/ip_output.c \
$(MELON_DIR)/libslirp-v4.6.1/src/mbuf.c \
$(MELON_DIR)/libslirp-v4.6.1/src/misc.c \
$(MELON_DIR)/libslirp-v4.6.1/src/ncsi.c \
$(MELON_DIR)/libslirp-v4.6.1/src/ndp_table.c \
$(MELON_DIR)/libslirp-v4.6.1/src/sbuf.c \
$(MELON_DIR)/libslirp-v4.6.1/src/slirp.c \
$(MELON_DIR)/libslirp-v4.6.1/src/socket.c \
$(MELON_DIR)/libslirp-v4.6.1/src/state.c \
$(MELON_DIR)/libslirp-v4.6.1/src/stream.c \
$(MELON_DIR)/libslirp-v4.6.1/src/tcp_input.c \
$(MELON_DIR)/libslirp-v4.6.1/src/tcp_output.c \
$(MELON_DIR)/libslirp-v4.6.1/src/tcp_subr.c \
$(MELON_DIR)/libslirp-v4.6.1/src/tcp_timer.c \
$(MELON_DIR)/libslirp-v4.6.1/src/tftp.c \
$(MELON_DIR)/libslirp-v4.6.1/src/udp.c \
$(MELON_DIR)/libslirp-v4.6.1/src/udp6.c \
$(MELON_DIR)/libslirp-v4.6.1/src/util.c \
$(MELON_DIR)/libslirp-v4.6.1/src/version.c \
$(MELON_DIR)/libslirp-v4.6.1/src/vmstate.c
INCFLAGS += -I$(MELON_DIR)/libslirp-v4.6.1/src `pkg-config --cflags glib-2.0`
DEFINES += -DHAVE_SLIRP
endif

ifeq ($(HAVE_THREADS), 1)
SOURCES_C += $(CORE_DIR)/libretro-common/rthreads/rthreads.c \
$(CORE_DIR)/libretro-common/rthreads/rsemaphore.c
Expand Down
50 changes: 11 additions & 39 deletions src/libretro/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
#include <sys/select.h>
#endif

#ifdef HAVE_PCAP
#include "libui_sdl/LAN_PCap.h"
#include "libui_sdl/LAN_Socket.h"
#ifdef HAVE_SLIRP
#include "frontend/qt_sdl/LAN_Socket.h"
#endif

#ifdef HAVE_LIBNX
Expand Down Expand Up @@ -360,59 +359,32 @@ namespace Platform

bool LAN_Init()
{
#ifdef HAVE_PCAP
if (Config::DirectLAN)
{
if (!LAN_PCap::Init(true))
return false;
}
else
{
if (!LAN_Socket::Init())
return false;
}

return true;
#else
return false;
#ifdef HAVE_SLIRP
return LAN_Socket::Init();
#endif
}

void LAN_DeInit()
{
// checkme. blarg
//if (Config::DirectLAN)
// LAN_PCap::DeInit();
//else
// LAN_Socket::DeInit();
#ifdef HAVE_PCAP
LAN_PCap::DeInit();
#ifdef HAVE_SLIRP
LAN_Socket::DeInit();
#endif
}

int LAN_SendPacket(u8* data, int len)
{
#ifdef HAVE_PCAP
if (Config::DirectLAN)
return LAN_PCap::SendPacket(data, len);
else
return LAN_Socket::SendPacket(data, len);
#else
return 0;
#ifdef HAVE_SLIRP
return LAN_Socket::SendPacket(data, len);
#endif
return 0;
}

int LAN_RecvPacket(u8* data)
{
#ifdef HAVE_PCAP
if (Config::DirectLAN)
return LAN_PCap::RecvPacket(data);
else
return LAN_Socket::RecvPacket(data);
#else
return 0;
#ifdef HAVE_SLIRP
return LAN_Socket::RecvPacket(data);
#endif
return 0;
}

#ifdef HAVE_OPENGL
Expand Down
58 changes: 58 additions & 0 deletions src/libslirp-v4.6.1/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
---
Language: Cpp
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false # although we like it, it creates churn
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: false # churn
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None # AlwaysBreakAfterDefinitionReturnType is taken into account
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterStruct: false
AfterUnion: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakStringLiterals: true
ColumnLimit: 80
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: '.*_BEGIN$' # only PREC_BEGIN ?
MacroBlockEnd: '.*_END$'
MaxEmptyLinesToKeep: 2
PointerAlignment: Right
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
UseTab: Never
...
11 changes: 11 additions & 0 deletions src/libslirp-v4.6.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.[aod]
*.gcda
*.gcno
*.gcov
*.lib
*.obj
/build/
/TAGS
/cscope*
/src/libslirp-version.h
/tags
43 changes: 43 additions & 0 deletions src/libslirp-v4.6.1/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
image: fedora:latest

variables:
DEPS: meson ninja-build
gcc pkg-config glib2-devel
mingw64-gcc mingw64-pkg-config mingw64-glib2
clang-analyzer git-core

before_script:
- dnf install -y $DEPS
- git fetch --tags https://gitlab.freedesktop.org/slirp/libslirp.git
- git describe

build:
script:
- meson --werror build || (cat build/meson-logs/meson-log.txt && exit 1)
- ninja -C build
- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
- ninja -C build scan-build

build-mingw64:
script:
- (mkdir buildw && cd buildw && mingw64-meson --werror) || (cat buildw/meson-logs/meson-log.txt && exit 1)
- ninja -C buildw

Coverity:
only:
refs:
- master
- coverity
script:
- dnf update -y
- dnf install -y curl clang
- curl -o /tmp/cov-analysis-linux64.tgz https://scan.coverity.com/download/linux64
--form project=$COVERITY_SCAN_PROJECT_NAME --form token=$COVERITY_SCAN_TOKEN
- tar xfz /tmp/cov-analysis-linux64.tgz
- CC=clang meson build
- cov-analysis-linux64-*/bin/cov-build --dir cov-int ninja -C build
- tar cfz cov-int.tar.gz cov-int
- curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
--form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL
--form [email protected] --form version="`git describe --tags`"
--form description="`git describe --tags` / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID "
3 changes: 3 additions & 0 deletions src/libslirp-v4.6.1/.gitpublish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[gitpublishprofile "default"]
base = master
to = [email protected]
Loading