Comment: | Add socket support for Nintendo 3DS
This removes the port registry that existed for the Wii and instead This also includes several other socket-related cleanups. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
12b8a7552e23d92cbc550fcf23667ec3 |
User & Date: | js on 2016-03-27 23:10:53 |
Other Links: | manifest | tags |
2016-03-27
| ||
23:17 | 3DS: Add OoT3D as title large enough for injection check-in: 6344bdd11e user: js tags: trunk | |
23:10 | Add socket support for Nintendo 3DS check-in: 12b8a7552e user: js tags: trunk | |
2016-03-20
| ||
19:16 | PLATFORMS.md: Add Nintendo 3DS check-in: c0d11dd852 user: js tags: trunk | |
Modified PLATFORMS.md from [5197f7dabc] to [aa4baad7db].
︙ | |||
97 98 99 100 101 102 103 | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | - + | Nintendo 3DS ------------ * OS Versions: 9.2.0-20E, 10.5.0-30E / Homebrew Channel 1.1.0 * Architectures: ARM (EABI) * Compilers: GCC 5.3.0 (devkitARM release 45) * Runtimes: ObjFW |
︙ |
Modified configure.ac from [7ffad8963b] to [b7c049a721].
︙ | |||
100 101 102 103 104 105 106 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | - | OBJCFLAGS="$OBJCFLAGS -mtp=soft -mword-relocations" CPPFLAGS="$CPPFLAGS -DARM11 -I$DEVKITPRO/libctru/include" LDFLAGS="$LDFLAGS -specs=3dsx.specs -march=armv6k -mtune=mpcore" LDFLAGS="$LDFLAGS -mfloat-abi=hard -mtp=soft -mword-relocations" LIBS="$LIBS -L$DEVKITPRO/libctru/lib -lctru" enable_shared="no" enable_threads="no" # TODO |
︙ | |||
839 840 841 842 843 844 845 846 847 848 849 850 851 852 | 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | [Whether we have netinet/in.h]) ]) AC_CHECK_HEADER(netinet/tcp.h, [ AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1, [Whether we have netinet/tcp.h]) ]) AC_CHECK_HEADERS([arpa/inet.h netdb.h]) AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [ AC_EGREP_CPP(yes, [ #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #ifdef _WIN32 # ifdef __MINGW32__ # include <_mingw.h> # ifdef __MINGW64_VERSION_MAJOR # include <winsock2.h> # endif # endif # include <windows.h> # include <ws2tcpip.h> #endif #ifdef AF_INET6 yes #endif ], [ AC_DEFINE(OF_HAVE_IPV6, 1, [Whether we have IPv6]) ]) ], [ ], [ #ifdef OF_HAVE_NETINET_IN_H # include <netinet/in.h> #endif #ifdef _WIN32 # ifdef __MINGW32__ # include <_mingw.h> # ifdef __MINGW64_VERSION_MAJOR # include <winsock2.h> # endif # endif # include <windows.h> # include <ws2tcpip.h> #endif ]) AC_CHECK_FUNCS([paccept accept4]) AC_CHECK_FUNC(kqueue, [ AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue]) AC_SUBST(OFKERNELEVENTOBSERVER_KQUEUE_M, "OFKernelEventObserver_kqueue.m") |
︙ |
Modified src/OFKernelEventObserver.m from [e992bd3e10] to [abf69b00a7].
︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | + + | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #define __NO_EXT_QNX #include "config.h" #include <errno.h> #import "OFKernelEventObserver.h" #import "OFKernelEventObserver+Private.h" #import "OFArray.h" #import "OFDataArray.h" #import "OFStream.h" #import "OFStream+Private.h" |
︙ | |||
97 98 99 100 101 102 103 | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | - + - - - + - + - + + + + + + + + + + + + + + + + + + + | } - init { self = [super init]; @try { |
︙ | |||
160 161 162 163 164 165 166 | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | - - - - | - (void)dealloc { close(_cancelFD[0]); if (_cancelFD[1] != _cancelFD[0]) close(_cancelFD[1]); |
︙ |
Modified src/OFTCPSocket.h from [3d379a0b72] to [1b9fd13a4f].
︙ | |||
63 64 65 66 67 68 69 | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | - | bool _listening; struct sockaddr *_address; socklen_t _addressLength; OFString *_SOCKS5Host; uint16_t _SOCKS5Port; #ifdef OF_WII uint16_t _port; |
︙ | |||
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | + + + + + + + + + + + + | /*! * @brief Returns whether the socket is a listening socket. * * @return Whether the socket is a listening socket */ - (bool)isListening; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) /*! * @brief Enable or disable keep alive for the connection. * * @warning This is not available on the Wii or Nintendo 3DS! * * @param enabled Whether to enable or disable keep alives for the connection */ - (void)setKeepAliveEnabled: (bool)enabled; /*! * @brief Returns whether keep alive is enabled for the connection. * * @warning This is not available on the Wii or Nintendo 3DS! * * @return Whether keep alives are enabled for the connection */ - (bool)isKeepAliveEnabled; #endif #ifndef OF_WII /*! * @brief Enable or disable TCP_NODELAY for the connection. * * @warning This is not available on the Wii! * * @param enabled Whether to enable or disable TCP_NODELAY for the connection */ - (void)setTCPNoDelayEnabled: (bool)enabled; /*! * @brief Returns whether TCP_NODELAY is enabled for the connection. * * @warning This is not available on the Wii! * * @return Whether TCP_NODELAY is enabled for the connection */ - (bool)isTCPNoDelayEnabled; #endif @end #ifdef __cplusplus extern "C" { #endif extern Class _Nullable of_tls_socket_class; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/OFTCPSocket.m from [ccb8fac7b9] to [f48a1756ef].
︙ | |||
240 241 242 243 244 245 246 | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | - - - - - - - - - - - - | - (void)dealloc { [_SOCKS5Host release]; [super dealloc]; } |
︙ | |||
366 367 368 369 370 371 372 | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | - + - + - - - - - - - - - - - - + - - - - - - - | #endif - (uint16_t)bindToHost: (OFString*)host port: (uint16_t)port { of_resolver_result_t **results; const int one = 1; |
︙ | |||
425 426 427 428 429 430 431 | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | + + + - - - + + + - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - + + - - + | if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one, (socklen_t)sizeof(one)); #if defined(OF_WII) || defined(OF_NINTENDO_3DS) if (port != 0) { #endif |
︙ | |||
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | + - - - - - - - + - - + + - - - - - - - - + | } - (bool)isListening { return _listening; } #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) - (void)setKeepAliveEnabled: (bool)enabled { int v = enabled; if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, (socklen_t)sizeof(v)) != 0) @throw [OFSetOptionFailedException exceptionWithStream: self errNo: of_socket_errno()]; |
Modified src/OFUDPSocket.m from [40c5efdd20] to [ad50b942db].
︙ | |||
172 173 174 175 176 177 178 | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | - + - + - + | #endif bool of_udp_socket_address_equal(of_udp_socket_address_t *address1, of_udp_socket_address_t *address2) { struct sockaddr_in *sin_1, *sin_2; |
︙ | |||
229 230 231 232 233 234 235 | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | - + - + - + | } uint32_t of_udp_socket_address_hash(of_udp_socket_address_t *address) { uint32_t hash = of_hash_seed; struct sockaddr_in *sin; |
︙ | |||
381 382 383 384 385 386 387 | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | - + - + - - - - - - - - - - - - + - - - - - - - + + + - - - + + + - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - + + - - + | return [self retain]; } - (uint16_t)bindToHost: (OFString*)host port: (uint16_t)port { of_resolver_result_t **results; |
︙ | |||
620 621 622 623 624 625 626 | 647 648 649 650 651 652 653 654 655 | - + - - - - - - - | - (void)close { if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; close(_socket); _socket = INVALID_SOCKET; |
Modified src/objfw-defs.h.in from [793b73003c] to [84b0a50859].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + | #undef OF_APPLE_RUNTIME #undef OF_BIG_ENDIAN #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_ATOMIC_OPS #undef OF_HAVE_BUILTIN_BSWAP16 #undef OF_HAVE_BUILTIN_BSWAP32 #undef OF_HAVE_BUILTIN_BSWAP64 #undef OF_HAVE_CHMOD #undef OF_HAVE_CHOWN #undef OF_HAVE_FILES #undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR #undef OF_HAVE_GCC_ATOMIC_OPS #undef OF_HAVE_IPV6 #undef OF_HAVE_LINK #undef OF_HAVE_MAX_ALIGN_T #undef OF_HAVE_NETINET_IN_H #undef OF_HAVE_OSATOMIC #undef OF_HAVE_OSATOMIC_64 #undef OF_HAVE_PIPE #undef OF_HAVE_PLUGINS |
︙ |
Modified src/socket.h from [f7e5adc4a8] to [854e84e0a1].
︙ | |||
83 84 85 86 87 88 89 | 83 84 85 86 87 88 89 90 91 92 93 94 95 | - - - - | extern "C" { #endif extern bool of_socket_init(void); extern int of_socket_errno(void); # ifndef OF_WII extern int of_getsockname(of_socket_t socket, struct sockaddr *restrict address, socklen_t *restrict address_len); |
Modified src/socket.m from [deff42ec22] to [1832892042].
︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | + + + + + + + + + + + | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #ifdef OF_NINTENDO_3DS # include <malloc.h> /* For memalign() */ #endif #include <errno.h> #import "OFException.h" /* For some E* -> WSAE* defines */ #import "OFInvalidArgumentException.h" #import "OFLockFailedException.h" #import "OFUnlockFailedException.h" #import "socket.h" #ifdef OF_HAVE_THREADS # include "threading.h" #endif #ifdef OF_NINTENDO_3DS # include <3ds/types.h> # include <3ds/services/soc.h> #endif #ifdef OF_HAVE_THREADS static of_once_t onceControl = OF_ONCE_INIT; static of_mutex_t mutex; #endif static bool initialized = false; #ifdef OF_WII # ifdef OF_HAVE_THREADS |
︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | + + + + + + + + + + | WSADATA wsa; if (WSAStartup(MAKEWORD(2, 0), &wsa)) return; #elif defined(OF_WII) if (net_init() < 0) return; #elif defined(OF_NINTENDO_3DS) void *ctx; if ((ctx = memalign(0x1000, 0x100000)) == NULL) return; if (socInit(ctx, 0x100000) != 0) return; atexit((void(*))socExit); #endif #ifdef OF_HAVE_THREADS if (!of_mutex_new(&mutex)) return; # ifdef OF_WII |
︙ | |||
195 196 197 198 199 200 201 | 216 217 218 219 220 221 222 223 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | # ifdef OF_HAVE_THREADS if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exception]; # endif return ret; } |
Modified src/socket_helpers.h from [e6b3708f36] to [3a4f887125].
︙ | |||
46 47 48 49 50 51 52 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | + + + + - + - - - - - | #endif #ifndef INADDR_NONE # define INADDR_NONE ((in_addr_t)-1) #endif #ifndef SOMAXCONN /* * Use 16 as everything > 17 fails on Nintendo 3DS and 16 is a less arbitrary * number than 17. */ |
︙ |
Modified utils/ofhttp/ProgressBar.m from [e437710ddc] to [d83aef3f71].
︙ | |||
90 91 92 93 94 95 96 | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | - + | _received = received; } - (void)_drawProgress { float bars, percent; unsigned short barWidth; |
︙ |