Repository navigation
feat: package lwIP for Xbox #12
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # This file is used by SonarQube Cloud automatic analysis; it ignores sonar-project.properties. | ||
| # https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/automatic-analysis#additional-analysis-configuration | ||
|
|
||
| sonar.exclusions=lib/libcxx/**,lib/net/lwip/**,lib/pdclib/**,lib/usb/libusbohci/**,tools/extract-xiso/** | ||
| sonar.test.exclusions=lib/libcxx/**,lib/net/lwip/**,lib/pdclib/**,lib/usb/libusbohci/**,tools/extract-xiso/** | ||
| sonar.exclusions=lib/libcxx/**,lib/pdclib/**,lib/usb/libusbohci/**,tools/extract-xiso/** | ||
| sonar.test.exclusions=lib/libcxx/**,lib/pdclib/**,lib/usb/libusbohci/**,tools/extract-xiso/** |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2022 Stefan Schmidt | ||
| Copyright (c) 2022 Ryan Wendland | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| pkgname=lwip | ||
| pkgver=2.2.1 | ||
| pkgrel=1 | ||
| pkgdesc='Lightweight TCP/IP stack with the Xbox Ethernet integration' | ||
| arch=('xbox') | ||
| url='https://savannah.nongnu.org/projects/lwip/' | ||
| license=( | ||
| 'BSD-3-Clause' | ||
| 'MIT' | ||
| ) | ||
| makedepends=( | ||
| 'clang' | ||
| 'llvm' | ||
| 'make' | ||
| ) | ||
| options=( | ||
| 'staticlibs' | ||
| '!strip' | ||
| '!debug' | ||
| '!lto' | ||
| '!buildflags' | ||
| ) | ||
| _lwip_tag=STABLE-${pkgver//./_}_RELEASE | ||
| source=( | ||
| "lwip-$pkgver.tar.gz::https://codeload.github.com/lwip-tcpip/lwip/tar.gz/refs/tags/$_lwip_tag" | ||
| 'lwip.mk' | ||
| 'LICENSE.xbdk' | ||
| ) | ||
| sha256sums=( | ||
| 'ce0b7461c0ad9602c376f0bf07c5eb7253b48c7bf66f011c6bf3e2a96731c539' | ||
| 'f2a457542b63bd8eca3a8400d431c3010829404bbb957168c9723d80fb46b671' | ||
| '52f4934ed1f63834fd75a846349b57022f7b7eba7ed0fbbd6ad5905231175f7b' | ||
| ) | ||
|
|
||
| build() { | ||
| export PATH="${NXDK_DIR:?Set NXDK_DIR to the XbFoundry/xbdk checkout for this build}/bin:$PATH" | ||
| make -f "$srcdir/lwip.mk" LWIPDIR="$srcdir/lwip-$_lwip_tag/src" CFLAGS=-O2 libnxdk_net.lib | ||
| } | ||
|
|
||
| check() { | ||
| local symbols symbol | ||
| symbols=$(llvm-nm --defined-only --extern-only --format=posix "$srcdir/libnxdk_net.lib") | ||
| for symbol in _tcpip_init _lwip_socket _nxNetInit _nvnetif_init; do | ||
| if ! grep -q "^${symbol} " <<< "$symbols"; then | ||
| printf 'lwIP archive is missing %s\n' "$symbol" >&2 | ||
| return 1 | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| package() { | ||
| local prefix=$pkgdir${XBOX_PREFIX:-/opt/xbfoundry/xbox} | ||
| local lwip_dir=$srcdir/lwip-$_lwip_tag | ||
| local xbox_net=$NXDK_DIR/lib/net | ||
| local headers=$prefix/include/lwip | ||
| local licenses=$prefix/share/licenses/$pkgname | ||
|
|
||
| install -Dm644 "$srcdir/libnxdk_net.lib" "$prefix/lib/libnxdk_net.lib" | ||
| install -d "$headers" | ||
| cp -R "$lwip_dir/src/include/." "$headers/" | ||
| cp -R "$xbox_net/nforceif/include/." "$headers/" | ||
| install -Dm644 -t "$headers" "$xbox_net"/nvnetdrv/*.h | ||
| install -Dm644 "$lwip_dir/COPYING" "$licenses/lwip.txt" | ||
| install -Dm644 "$srcdir/LICENSE.xbdk" "$licenses/xbdk.txt" | ||
| # Preserve the Xbox port's BSD notices for the compiled driver and sys_arch. | ||
| { | ||
| sed -n '1,/^ \*\//p' "$xbox_net/nforceif/src/sys_arch.c" | ||
| sed -n '/^\/\/ SPDX-FileCopyrightText: /p' "$xbox_net/nvnetdrv/nvnetdrv_lwip.c" | ||
| } > "$licenses/xbox-port.txt" | ||
|
|
||
| install -d "$prefix/lib/pkgconfig" | ||
| cat > "$prefix/lib/pkgconfig/$pkgname.pc" <<EOF | ||
| prefix=\${pcfiledir}/../.. | ||
| libdir=\${prefix}/lib | ||
| includedir=\${prefix}/include/lwip | ||
|
|
||
| Name: lwIP | ||
| Description: $pkgdesc | ||
| Version: $pkgver | ||
| Libs: \${libdir}/libnxdk_net.lib | ||
| Cflags: -I\${includedir} | ||
| EOF | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||
| # Build lwIP and the SDK's Xbox network integration into one archive. | ||||||
| include $(LWIPDIR)/Filelists.mk | ||||||
|
|
||||||
| XBDK_NET := $(NXDK_DIR)/lib/net | ||||||
| LWIP_SOURCES := $(COREFILES) $(CORE4FILES) $(CORE6FILES) $(APIFILES) \ | ||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Build the discovery and socket features Sunshine uses before switching it to this package Sunshine's current Xbox build compiles the mDNS sources with IGMP and per-interface client storage. It also enables socket receive timeouts for pairing and receive-buffer sizing for streaming. This archive omits the mDNS and IGMP symbols. I linked the exact CI package in xemu and both The source-list change below goes with enabling With those changes, the local guest accepted both socket options, read back the selected receive buffer, registered the interface for mDNS, and started a discovery search. The probe checked local API behavior in xemu.
Suggested change
Review completed by Codex | Model: gpt-6.2-sol | Thinking: xhigh |
||||||
| $(filter-out $(LWIPDIR)/netif/slipif.c,$(NETIFFILES)) | ||||||
| XBOX_SOURCES := $(XBDK_NET)/nforceif/src/sys_arch.c \ | ||||||
| $(XBDK_NET)/nvnetdrv/nvnetdrv.c \ | ||||||
| $(XBDK_NET)/nvnetdrv/nvnetdrv_lwip.c \ | ||||||
| $(NXDK_DIR)/lib/nxdk/net.c | ||||||
|
|
||||||
| SOURCES := $(LWIP_SOURCES) $(XBOX_SOURCES) | ||||||
| OBJECTS := $(notdir $(SOURCES:.c=.obj)) | ||||||
| vpath %.c $(sort $(dir $(SOURCES))) | ||||||
|
|
||||||
| CPPFLAGS += -I$(LWIPDIR)/include -I$(XBDK_NET)/nforceif/include -I$(XBDK_NET)/nvnetdrv | ||||||
|
|
||||||
| libnxdk_net.lib: $(OBJECTS) | ||||||
| llvm-lib "-out:$@" $^ | ||||||
|
|
||||||
| %.obj: %.c | ||||||
| nxdk-cc $(CPPFLAGS) $(CFLAGS) -c "$<" -o "$@" | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| PACKAGE_MODULES += lwip |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #include <gtest/gtest.h> | ||
|
|
||
| #include <lwip/sockets.h> | ||
| #include <nxdk/net.h> | ||
|
|
||
| TEST(LwipPackage, InitializesXboxNetworkingAndBindsUdpSocket) | ||
| { | ||
| nx_net_parameters_t parameters{}; | ||
| parameters.ipv4_mode = NX_NET_STATIC; | ||
| parameters.ipv4_ip = PP_HTONL(LWIP_MAKEU32(10, 0, 2, 15)); | ||
| parameters.ipv4_netmask = PP_HTONL(LWIP_MAKEU32(255, 255, 255, 0)); | ||
| ASSERT_EQ(nxNetInit(¶meters), 0); | ||
|
|
||
| const int socket = lwip_socket(AF_INET, SOCK_DGRAM, 0); | ||
| ASSERT_GE(socket, 0); | ||
|
|
||
| sockaddr_in address{}; | ||
| address.sin_family = AF_INET; | ||
| address.sin_addr.s_addr = parameters.ipv4_ip; | ||
| const int bind_result = lwip_bind(socket, reinterpret_cast<const sockaddr *>(&address), sizeof(address)); | ||
|
|
||
| socklen_t length = sizeof(address); | ||
| const int name_result = lwip_getsockname(socket, reinterpret_cast<sockaddr *>(&address), &length); | ||
| EXPECT_EQ(lwip_close(socket), 0); | ||
| ASSERT_EQ(bind_result, 0); | ||
| ASSERT_EQ(name_result, 0); | ||
| EXPECT_EQ(address.sin_addr.s_addr, parameters.ipv4_ip); | ||
| EXPECT_NE(address.sin_port, 0); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep lwIP installation instructions beside its recipe
Move the install and
NXDK_NET=yguidance intopkgbuilds/lwip/README.md. The package descriptions in the overview work as links to the individual packages.Review completed by Codex | Model: gpt-6.2-sol | Thinking: xhigh