uws-react-native 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +84 -0
- package/UwsReactNative.podspec +71 -0
- package/android/build.gradle.kts +138 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/id/sufeni/oss/uwsreactnative/UwsReactNativePackage.kt +18 -0
- package/apple/OnLoad.mm +17 -0
- package/cpp/CMakeLists.txt +154 -0
- package/cpp/UwsReactNativeModule.cpp +191 -0
- package/cpp/UwsReactNativeModule.h +30 -0
- package/cpp/app/AppHost.h +37 -0
- package/cpp/app/AppRunner.h +88 -0
- package/cpp/app/CMakeLists.txt +39 -0
- package/cpp/app/HttpRequestObject.h +173 -0
- package/cpp/app/HttpResponseObject.h +623 -0
- package/cpp/app/RecognizedString.h +71 -0
- package/cpp/app/TemplatedAppObject.h +472 -0
- package/cpp/bridging/ArrayBuffer.h +150 -0
- package/cpp/bridging/CMakeLists.txt +34 -0
- package/cpp/jsi/Buffer.h +91 -0
- package/cpp/jsi/CMakeLists.txt +34 -0
- package/cpp/uSockets/bsd.c +767 -0
- package/cpp/uSockets/context.c +524 -0
- package/cpp/uSockets/crypto/openssl.c +858 -0
- package/cpp/uSockets/crypto/sni_tree.cpp +218 -0
- package/cpp/uSockets/eventing/asio.cpp +475 -0
- package/cpp/uSockets/eventing/epoll_kqueue.c +458 -0
- package/cpp/uSockets/eventing/gcd.c +278 -0
- package/cpp/uSockets/eventing/libuv.c +305 -0
- package/cpp/uSockets/internal/eventing/asio.h +45 -0
- package/cpp/uSockets/internal/eventing/epoll_kqueue.h +67 -0
- package/cpp/uSockets/internal/eventing/gcd.h +40 -0
- package/cpp/uSockets/internal/eventing/libuv.h +45 -0
- package/cpp/uSockets/internal/internal.h +224 -0
- package/cpp/uSockets/internal/loop_data.h +38 -0
- package/cpp/uSockets/internal/networking/bsd.h +109 -0
- package/cpp/uSockets/io_uring/internal.h +98 -0
- package/cpp/uSockets/io_uring/io_context.c +302 -0
- package/cpp/uSockets/io_uring/io_loop.c +422 -0
- package/cpp/uSockets/io_uring/io_socket.c +139 -0
- package/cpp/uSockets/libusockets.h +350 -0
- package/cpp/uSockets/loop.c +396 -0
- package/cpp/uSockets/quic.c +1071 -0
- package/cpp/uSockets/quic.h +68 -0
- package/cpp/uSockets/socket.c +231 -0
- package/cpp/uSockets/udp.c +151 -0
- package/cpp/uWebSockets/uWebSockets/App.h +676 -0
- package/cpp/uWebSockets/uWebSockets/AsyncSocket.h +376 -0
- package/cpp/uWebSockets/uWebSockets/AsyncSocketData.h +94 -0
- package/cpp/uWebSockets/uWebSockets/BloomFilter.h +83 -0
- package/cpp/uWebSockets/uWebSockets/CachingApp.h +115 -0
- package/cpp/uWebSockets/uWebSockets/ChunkedEncoding.h +237 -0
- package/cpp/uWebSockets/uWebSockets/ClientApp.h +36 -0
- package/cpp/uWebSockets/uWebSockets/Http3App.h +140 -0
- package/cpp/uWebSockets/uWebSockets/Http3Context.h +157 -0
- package/cpp/uWebSockets/uWebSockets/Http3ContextData.h +21 -0
- package/cpp/uWebSockets/uWebSockets/Http3Request.h +22 -0
- package/cpp/uWebSockets/uWebSockets/Http3Response.h +120 -0
- package/cpp/uWebSockets/uWebSockets/Http3ResponseData.h +25 -0
- package/cpp/uWebSockets/uWebSockets/HttpContext.h +521 -0
- package/cpp/uWebSockets/uWebSockets/HttpContextData.h +60 -0
- package/cpp/uWebSockets/uWebSockets/HttpErrors.h +53 -0
- package/cpp/uWebSockets/uWebSockets/HttpParser.h +747 -0
- package/cpp/uWebSockets/uWebSockets/HttpResponse.h +605 -0
- package/cpp/uWebSockets/uWebSockets/HttpResponseData.h +123 -0
- package/cpp/uWebSockets/uWebSockets/HttpRouter.h +384 -0
- package/cpp/uWebSockets/uWebSockets/LocalCluster.h +64 -0
- package/cpp/uWebSockets/uWebSockets/Loop.h +238 -0
- package/cpp/uWebSockets/uWebSockets/LoopData.h +113 -0
- package/cpp/uWebSockets/uWebSockets/MessageParser.h +64 -0
- package/cpp/uWebSockets/uWebSockets/MoveOnlyFunction.h +389 -0
- package/cpp/uWebSockets/uWebSockets/Multipart.h +231 -0
- package/cpp/uWebSockets/uWebSockets/PerMessageDeflate.h +303 -0
- package/cpp/uWebSockets/uWebSockets/ProxyParser.h +187 -0
- package/cpp/uWebSockets/uWebSockets/QueryParser.h +120 -0
- package/cpp/uWebSockets/uWebSockets/TopicTree.h +364 -0
- package/cpp/uWebSockets/uWebSockets/Utilities.h +66 -0
- package/cpp/uWebSockets/uWebSockets/WebSocket.h +407 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketContext.h +436 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketContextData.h +109 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketData.h +86 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketExtensions.h +256 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketHandshake.h +145 -0
- package/cpp/uWebSockets/uWebSockets/WebSocketProtocol.h +525 -0
- package/lib/commonjs/_internal/native-modules/NativeReactNativeUws.js +12 -0
- package/lib/commonjs/_internal/native-modules/NativeReactNativeUws.js.map +1 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/modules/App.js +17 -0
- package/lib/commonjs/modules/App.js.map +1 -0
- package/lib/commonjs/modules/CompressOptions.js +103 -0
- package/lib/commonjs/modules/CompressOptions.js.map +1 -0
- package/lib/commonjs/modules/EnvironmentVariables.js +17 -0
- package/lib/commonjs/modules/EnvironmentVariables.js.map +1 -0
- package/lib/commonjs/modules/ListenOptions.js +12 -0
- package/lib/commonjs/modules/ListenOptions.js.map +1 -0
- package/lib/commonjs/modules/SSLApp.js +15 -0
- package/lib/commonjs/modules/SSLApp.js.map +1 -0
- package/lib/commonjs/modules/getParts.js +28 -0
- package/lib/commonjs/modules/getParts.js.map +1 -0
- package/lib/commonjs/modules/index.js +61 -0
- package/lib/commonjs/modules/index.js.map +1 -0
- package/lib/commonjs/modules/us_listen_socket_close.js +21 -0
- package/lib/commonjs/modules/us_listen_socket_close.js.map +1 -0
- package/lib/commonjs/modules/us_socket_local_port.js +22 -0
- package/lib/commonjs/modules/us_socket_local_port.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types/AppDescriptor.js +2 -0
- package/lib/commonjs/types/AppDescriptor.js.map +1 -0
- package/lib/commonjs/types/AppOptions.js +2 -0
- package/lib/commonjs/types/AppOptions.js.map +1 -0
- package/lib/commonjs/types/HttpRequest.js +6 -0
- package/lib/commonjs/types/HttpRequest.js.map +1 -0
- package/lib/commonjs/types/HttpResponse.js +6 -0
- package/lib/commonjs/types/HttpResponse.js.map +1 -0
- package/lib/commonjs/types/HttpRouterOptions.js +2 -0
- package/lib/commonjs/types/HttpRouterOptions.js.map +1 -0
- package/lib/commonjs/types/MultipartField.js +2 -0
- package/lib/commonjs/types/MultipartField.js.map +1 -0
- package/lib/commonjs/types/RecognizedString.js +2 -0
- package/lib/commonjs/types/RecognizedString.js.map +1 -0
- package/lib/commonjs/types/TemplatedApp.js +6 -0
- package/lib/commonjs/types/TemplatedApp.js.map +1 -0
- package/lib/commonjs/types/WebSocket.js +6 -0
- package/lib/commonjs/types/WebSocket.js.map +1 -0
- package/lib/commonjs/types/WebSocketBehaviour.js +139 -0
- package/lib/commonjs/types/WebSocketBehaviour.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/us_listen_socket.js +2 -0
- package/lib/commonjs/types/us_listen_socket.js.map +1 -0
- package/lib/commonjs/types/us_socket.js +2 -0
- package/lib/commonjs/types/us_socket.js.map +1 -0
- package/lib/commonjs/types/us_socket_context_t.js +2 -0
- package/lib/commonjs/types/us_socket_context_t.js.map +1 -0
- package/lib/module/_internal/native-modules/NativeReactNativeUws.js +10 -0
- package/lib/module/_internal/native-modules/NativeReactNativeUws.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/modules/App.js +12 -0
- package/lib/module/modules/App.js.map +1 -0
- package/lib/module/modules/CompressOptions.js +103 -0
- package/lib/module/modules/CompressOptions.js.map +1 -0
- package/lib/module/modules/EnvironmentVariables.js +13 -0
- package/lib/module/modules/EnvironmentVariables.js.map +1 -0
- package/lib/module/modules/ListenOptions.js +8 -0
- package/lib/module/modules/ListenOptions.js.map +1 -0
- package/lib/module/modules/SSLApp.js +15 -0
- package/lib/module/modules/SSLApp.js.map +1 -0
- package/lib/module/modules/getParts.js +23 -0
- package/lib/module/modules/getParts.js.map +1 -0
- package/lib/module/modules/index.js +11 -0
- package/lib/module/modules/index.js.map +1 -0
- package/lib/module/modules/us_listen_socket_close.js +17 -0
- package/lib/module/modules/us_listen_socket_close.js.map +1 -0
- package/lib/module/modules/us_socket_local_port.js +18 -0
- package/lib/module/modules/us_socket_local_port.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types/AppDescriptor.js +2 -0
- package/lib/module/types/AppDescriptor.js.map +1 -0
- package/lib/module/types/AppOptions.js +2 -0
- package/lib/module/types/AppOptions.js.map +1 -0
- package/lib/module/types/HttpRequest.js +4 -0
- package/lib/module/types/HttpRequest.js.map +1 -0
- package/lib/module/types/HttpResponse.js +4 -0
- package/lib/module/types/HttpResponse.js.map +1 -0
- package/lib/module/types/HttpRouterOptions.js +2 -0
- package/lib/module/types/HttpRouterOptions.js.map +1 -0
- package/lib/module/types/MultipartField.js +2 -0
- package/lib/module/types/MultipartField.js.map +1 -0
- package/lib/module/types/RecognizedString.js +2 -0
- package/lib/module/types/RecognizedString.js.map +1 -0
- package/lib/module/types/TemplatedApp.js +4 -0
- package/lib/module/types/TemplatedApp.js.map +1 -0
- package/lib/module/types/WebSocket.js +4 -0
- package/lib/module/types/WebSocket.js.map +1 -0
- package/lib/module/types/WebSocketBehaviour.js +139 -0
- package/lib/module/types/WebSocketBehaviour.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/us_listen_socket.js +2 -0
- package/lib/module/types/us_listen_socket.js.map +1 -0
- package/lib/module/types/us_socket.js +2 -0
- package/lib/module/types/us_socket.js.map +1 -0
- package/lib/module/types/us_socket_context_t.js +2 -0
- package/lib/module/types/us_socket_context_t.js.map +1 -0
- package/lib/typescript/commonjs/_internal/native-modules/NativeReactNativeUws.d.ts +22 -0
- package/lib/typescript/commonjs/_internal/native-modules/NativeReactNativeUws.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +3 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/App.d.ts +7 -0
- package/lib/typescript/commonjs/modules/App.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/CompressOptions.d.ts +1 -0
- package/lib/typescript/commonjs/modules/CompressOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/EnvironmentVariables.d.ts +16 -0
- package/lib/typescript/commonjs/modules/EnvironmentVariables.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/ListenOptions.d.ts +5 -0
- package/lib/typescript/commonjs/modules/ListenOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/SSLApp.d.ts +1 -0
- package/lib/typescript/commonjs/modules/SSLApp.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/getParts.d.ts +6 -0
- package/lib/typescript/commonjs/modules/getParts.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/index.d.ts +6 -0
- package/lib/typescript/commonjs/modules/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/us_listen_socket_close.d.ts +5 -0
- package/lib/typescript/commonjs/modules/us_listen_socket_close.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/us_socket_local_port.d.ts +5 -0
- package/lib/typescript/commonjs/modules/us_socket_local_port.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/types/AppDescriptor.d.ts +8 -0
- package/lib/typescript/commonjs/types/AppDescriptor.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/AppOptions.d.ts +17 -0
- package/lib/typescript/commonjs/types/AppOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/HttpRequest.d.ts +54 -0
- package/lib/typescript/commonjs/types/HttpRequest.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/HttpResponse.d.ts +169 -0
- package/lib/typescript/commonjs/types/HttpResponse.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/HttpRouterOptions.d.ts +24 -0
- package/lib/typescript/commonjs/types/HttpRouterOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/MultipartField.d.ts +7 -0
- package/lib/typescript/commonjs/types/MultipartField.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/RecognizedString.d.ts +10 -0
- package/lib/typescript/commonjs/types/RecognizedString.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/TemplatedApp.d.ts +108 -0
- package/lib/typescript/commonjs/types/TemplatedApp.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/WebSocket.d.ts +96 -0
- package/lib/typescript/commonjs/types/WebSocket.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts +1 -0
- package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/index.d.ts +6 -0
- package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/us_listen_socket.d.ts +7 -0
- package/lib/typescript/commonjs/types/us_listen_socket.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/us_socket.d.ts +7 -0
- package/lib/typescript/commonjs/types/us_socket.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/us_socket_context_t.d.ts +7 -0
- package/lib/typescript/commonjs/types/us_socket_context_t.d.ts.map +1 -0
- package/lib/typescript/module/_internal/native-modules/NativeReactNativeUws.d.ts +22 -0
- package/lib/typescript/module/_internal/native-modules/NativeReactNativeUws.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +3 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/modules/App.d.ts +7 -0
- package/lib/typescript/module/modules/App.d.ts.map +1 -0
- package/lib/typescript/module/modules/CompressOptions.d.ts +1 -0
- package/lib/typescript/module/modules/CompressOptions.d.ts.map +1 -0
- package/lib/typescript/module/modules/EnvironmentVariables.d.ts +16 -0
- package/lib/typescript/module/modules/EnvironmentVariables.d.ts.map +1 -0
- package/lib/typescript/module/modules/ListenOptions.d.ts +5 -0
- package/lib/typescript/module/modules/ListenOptions.d.ts.map +1 -0
- package/lib/typescript/module/modules/SSLApp.d.ts +1 -0
- package/lib/typescript/module/modules/SSLApp.d.ts.map +1 -0
- package/lib/typescript/module/modules/getParts.d.ts +6 -0
- package/lib/typescript/module/modules/getParts.d.ts.map +1 -0
- package/lib/typescript/module/modules/index.d.ts +6 -0
- package/lib/typescript/module/modules/index.d.ts.map +1 -0
- package/lib/typescript/module/modules/us_listen_socket_close.d.ts +5 -0
- package/lib/typescript/module/modules/us_listen_socket_close.d.ts.map +1 -0
- package/lib/typescript/module/modules/us_socket_local_port.d.ts +5 -0
- package/lib/typescript/module/modules/us_socket_local_port.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/types/AppDescriptor.d.ts +8 -0
- package/lib/typescript/module/types/AppDescriptor.d.ts.map +1 -0
- package/lib/typescript/module/types/AppOptions.d.ts +17 -0
- package/lib/typescript/module/types/AppOptions.d.ts.map +1 -0
- package/lib/typescript/module/types/HttpRequest.d.ts +54 -0
- package/lib/typescript/module/types/HttpRequest.d.ts.map +1 -0
- package/lib/typescript/module/types/HttpResponse.d.ts +169 -0
- package/lib/typescript/module/types/HttpResponse.d.ts.map +1 -0
- package/lib/typescript/module/types/HttpRouterOptions.d.ts +24 -0
- package/lib/typescript/module/types/HttpRouterOptions.d.ts.map +1 -0
- package/lib/typescript/module/types/MultipartField.d.ts +7 -0
- package/lib/typescript/module/types/MultipartField.d.ts.map +1 -0
- package/lib/typescript/module/types/RecognizedString.d.ts +10 -0
- package/lib/typescript/module/types/RecognizedString.d.ts.map +1 -0
- package/lib/typescript/module/types/TemplatedApp.d.ts +108 -0
- package/lib/typescript/module/types/TemplatedApp.d.ts.map +1 -0
- package/lib/typescript/module/types/WebSocket.d.ts +96 -0
- package/lib/typescript/module/types/WebSocket.d.ts.map +1 -0
- package/lib/typescript/module/types/WebSocketBehaviour.d.ts +1 -0
- package/lib/typescript/module/types/WebSocketBehaviour.d.ts.map +1 -0
- package/lib/typescript/module/types/index.d.ts +6 -0
- package/lib/typescript/module/types/index.d.ts.map +1 -0
- package/lib/typescript/module/types/us_listen_socket.d.ts +7 -0
- package/lib/typescript/module/types/us_listen_socket.d.ts.map +1 -0
- package/lib/typescript/module/types/us_socket.d.ts +7 -0
- package/lib/typescript/module/types/us_socket.d.ts.map +1 -0
- package/lib/typescript/module/types/us_socket_context_t.d.ts +7 -0
- package/lib/typescript/module/types/us_socket_context_t.d.ts.map +1 -0
- package/lib/typescript/tsconfig.tsbuildinfo +1 -0
- package/package.json +62 -0
- package/src/_internal/native-modules/NativeUwsReactNative.ts +40 -0
- package/src/index.ts +2 -0
- package/src/modules/App.ts +14 -0
- package/src/modules/CompressOptions.ts +101 -0
- package/src/modules/EnvironmentVariables.ts +16 -0
- package/src/modules/ListenOptions.ts +4 -0
- package/src/modules/SSLApp.ts +13 -0
- package/src/modules/getParts.ts +29 -0
- package/src/modules/index.ts +8 -0
- package/src/modules/us_listen_socket_close.ts +15 -0
- package/src/modules/us_socket_local_port.ts +16 -0
- package/src/types/AppDescriptor.ts +7 -0
- package/src/types/AppOptions.ts +22 -0
- package/src/types/HttpRequest.ts +74 -0
- package/src/types/HttpResponse.ts +309 -0
- package/src/types/HttpRouterOptions.ts +24 -0
- package/src/types/MultipartField.ts +6 -0
- package/src/types/RecognizedString.ts +11 -0
- package/src/types/TemplatedApp.ts +285 -0
- package/src/types/WebSocket.ts +147 -0
- package/src/types/WebSocketBehaviour.ts +137 -0
- package/src/types/index.ts +12 -0
- package/src/types/us_listen_socket.ts +6 -0
- package/src/types/us_socket.ts +6 -0
- package/src/types/us_socket_context_t.ts +6 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#ifdef LIBUS_USE_QUIC
|
|
2
|
+
|
|
3
|
+
#ifndef LIBUS_QUIC_H
|
|
4
|
+
#define LIBUS_QUIC_H
|
|
5
|
+
|
|
6
|
+
/* Experimental QUIC functions */
|
|
7
|
+
|
|
8
|
+
#include "libusockets.h"
|
|
9
|
+
|
|
10
|
+
typedef struct {
|
|
11
|
+
const char *cert_file_name;
|
|
12
|
+
const char *key_file_name;
|
|
13
|
+
const char *passphrase;
|
|
14
|
+
} us_quic_socket_context_options_t;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
typedef struct {
|
|
18
|
+
/* Refers to either the shared listen socket or the client UDP socket */
|
|
19
|
+
void *udp_socket;
|
|
20
|
+
} us_quic_socket_t;
|
|
21
|
+
|
|
22
|
+
struct us_quic_socket_context_s;
|
|
23
|
+
struct us_quic_listen_socket_s;
|
|
24
|
+
struct us_quic_stream_s;
|
|
25
|
+
|
|
26
|
+
typedef struct us_quic_socket_context_s us_quic_socket_context_t;
|
|
27
|
+
typedef struct us_quic_listen_socket_s us_quic_listen_socket_t;
|
|
28
|
+
typedef struct us_quic_stream_s us_quic_stream_t;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
void *us_quic_stream_ext(us_quic_stream_t *s);
|
|
32
|
+
int us_quic_stream_write(us_quic_stream_t *s, char *data, int length);
|
|
33
|
+
int us_quic_stream_shutdown(us_quic_stream_t *s);
|
|
34
|
+
int us_quic_stream_shutdown_read(us_quic_stream_t *s);
|
|
35
|
+
void us_quic_stream_close(us_quic_stream_t *s);
|
|
36
|
+
|
|
37
|
+
int us_quic_socket_context_get_header(us_quic_socket_context_t *context, int index, char **name, int *name_length, char **value, int *value_length);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
void us_quic_socket_context_set_header(us_quic_socket_context_t *context, int index, const char *key, int key_length, const char *value, int value_length);
|
|
41
|
+
void us_quic_socket_context_send_headers(us_quic_socket_context_t *context, us_quic_stream_t *s, int num, int has_body);
|
|
42
|
+
|
|
43
|
+
us_quic_socket_context_t *us_create_quic_socket_context(struct us_loop_t *loop, us_quic_socket_context_options_t options, int ext_size);
|
|
44
|
+
us_quic_listen_socket_t *us_quic_socket_context_listen(us_quic_socket_context_t *context, const char *host, int port, int ext_size);
|
|
45
|
+
us_quic_socket_t *us_quic_socket_context_connect(us_quic_socket_context_t *context, const char *host, int port, int ext_size);
|
|
46
|
+
|
|
47
|
+
void us_quic_socket_create_stream(us_quic_socket_t *s, int ext_size);
|
|
48
|
+
us_quic_socket_t *us_quic_stream_socket(us_quic_stream_t *s);
|
|
49
|
+
|
|
50
|
+
/* This one is ugly and is only used to make clean examples */
|
|
51
|
+
int us_quic_stream_is_client(us_quic_stream_t *s);
|
|
52
|
+
|
|
53
|
+
void us_quic_socket_context_on_stream_data(us_quic_socket_context_t *context, void(*on_stream_data)(us_quic_stream_t *s, char *data, int length));
|
|
54
|
+
void us_quic_socket_context_on_stream_end(us_quic_socket_context_t *context, void(*on_stream_data)(us_quic_stream_t *s));
|
|
55
|
+
void us_quic_socket_context_on_stream_headers(us_quic_socket_context_t *context, void(*on_stream_headers)(us_quic_stream_t *s));
|
|
56
|
+
void us_quic_socket_context_on_stream_open(us_quic_socket_context_t *context, void(*on_stream_open)(us_quic_stream_t *s, int is_client));
|
|
57
|
+
void us_quic_socket_context_on_stream_close(us_quic_socket_context_t *context, void(*on_stream_close)(us_quic_stream_t *s));
|
|
58
|
+
void us_quic_socket_context_on_open(us_quic_socket_context_t *context, void(*on_open)(us_quic_socket_t *s, int is_client));
|
|
59
|
+
void us_quic_socket_context_on_close(us_quic_socket_context_t *context, void(*on_close)(us_quic_socket_t *s));
|
|
60
|
+
void us_quic_socket_context_on_stream_writable(us_quic_socket_context_t *context, void(*on_stream_writable)(us_quic_stream_t *s));
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
void *us_quic_socket_context_ext(us_quic_socket_context_t *context);
|
|
65
|
+
us_quic_socket_context_t *us_quic_socket_context(us_quic_socket_t *s);
|
|
66
|
+
|
|
67
|
+
#endif
|
|
68
|
+
#endif
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Authored by Alex Hultman, 2018-2021.
|
|
3
|
+
* Intellectual property of third-party.
|
|
4
|
+
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef LIBUS_USE_IO_URING
|
|
19
|
+
|
|
20
|
+
#include "libusockets.h"
|
|
21
|
+
#include "internal/internal.h"
|
|
22
|
+
#include <stdlib.h>
|
|
23
|
+
#include <string.h>
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
|
|
26
|
+
/* Shared with SSL */
|
|
27
|
+
|
|
28
|
+
int us_socket_local_port(int ssl, struct us_socket_t *s) {
|
|
29
|
+
struct bsd_addr_t addr;
|
|
30
|
+
if (bsd_local_addr(us_poll_fd(&s->p), &addr)) {
|
|
31
|
+
return -1;
|
|
32
|
+
} else {
|
|
33
|
+
return bsd_addr_get_port(&addr);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
int us_socket_remote_port(int ssl, struct us_socket_t *s) {
|
|
38
|
+
struct bsd_addr_t addr;
|
|
39
|
+
if (bsd_remote_addr(us_poll_fd(&s->p), &addr)) {
|
|
40
|
+
return -1;
|
|
41
|
+
} else {
|
|
42
|
+
return bsd_addr_get_port(&addr);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void us_socket_shutdown_read(int ssl, struct us_socket_t *s) {
|
|
47
|
+
/* This syscall is idempotent so no extra check is needed */
|
|
48
|
+
bsd_shutdown_socket_read(us_poll_fd((struct us_poll_t *) s));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void us_socket_remote_address(int ssl, struct us_socket_t *s, char *buf, int *length) {
|
|
52
|
+
struct bsd_addr_t addr;
|
|
53
|
+
if (bsd_remote_addr(us_poll_fd(&s->p), &addr) || *length < bsd_addr_get_ip_length(&addr)) {
|
|
54
|
+
*length = 0;
|
|
55
|
+
} else {
|
|
56
|
+
*length = bsd_addr_get_ip_length(&addr);
|
|
57
|
+
memcpy(buf, bsd_addr_get_ip(&addr), *length);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
struct us_socket_context_t *us_socket_context(int ssl, struct us_socket_t *s) {
|
|
62
|
+
return s->context;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void us_socket_timeout(int ssl, struct us_socket_t *s, unsigned int seconds) {
|
|
66
|
+
if (seconds) {
|
|
67
|
+
s->timeout = ((unsigned int)s->context->timestamp + ((seconds + 3) >> 2)) % 240;
|
|
68
|
+
} else {
|
|
69
|
+
s->timeout = 255;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void us_socket_long_timeout(int ssl, struct us_socket_t *s, unsigned int minutes) {
|
|
74
|
+
if (minutes) {
|
|
75
|
+
s->long_timeout = ((unsigned int)s->context->long_timestamp + minutes) % 240;
|
|
76
|
+
} else {
|
|
77
|
+
s->long_timeout = 255;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void us_socket_flush(int ssl, struct us_socket_t *s) {
|
|
82
|
+
if (!us_socket_is_shut_down(0, s)) {
|
|
83
|
+
bsd_socket_flush(us_poll_fd((struct us_poll_t *) s));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
int us_socket_is_closed(int ssl, struct us_socket_t *s) {
|
|
88
|
+
return s->prev == (struct us_socket_t *) s->context;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
int us_socket_is_established(int ssl, struct us_socket_t *s) {
|
|
92
|
+
/* Everything that is not POLL_TYPE_SEMI_SOCKET is established */
|
|
93
|
+
return us_internal_poll_type((struct us_poll_t *) s) != POLL_TYPE_SEMI_SOCKET;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* Exactly the same as us_socket_close but does not emit on_close event */
|
|
97
|
+
struct us_socket_t *us_socket_close_connecting(int ssl, struct us_socket_t *s) {
|
|
98
|
+
if (!us_socket_is_closed(0, s)) {
|
|
99
|
+
us_internal_socket_context_unlink_socket(s->context, s);
|
|
100
|
+
us_poll_stop((struct us_poll_t *) s, s->context->loop);
|
|
101
|
+
bsd_close_socket(us_poll_fd((struct us_poll_t *) s));
|
|
102
|
+
|
|
103
|
+
/* Link this socket to the close-list and let it be deleted after this iteration */
|
|
104
|
+
s->next = s->context->loop->data.closed_head;
|
|
105
|
+
s->context->loop->data.closed_head = s;
|
|
106
|
+
|
|
107
|
+
/* Any socket with prev = context is marked as closed */
|
|
108
|
+
s->prev = (struct us_socket_t *) s->context;
|
|
109
|
+
|
|
110
|
+
//return s->context->on_close(s, code, reason);
|
|
111
|
+
}
|
|
112
|
+
return s;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* Same as above but emits on_close */
|
|
116
|
+
struct us_socket_t *us_socket_close(int ssl, struct us_socket_t *s, int code, void *reason) {
|
|
117
|
+
if (!us_socket_is_closed(0, s)) {
|
|
118
|
+
if (s->low_prio_state == 1) {
|
|
119
|
+
/* Unlink this socket from the low-priority queue */
|
|
120
|
+
if (!s->prev) s->context->loop->data.low_prio_head = s->next;
|
|
121
|
+
else s->prev->next = s->next;
|
|
122
|
+
|
|
123
|
+
if (s->next) s->next->prev = s->prev;
|
|
124
|
+
|
|
125
|
+
s->prev = 0;
|
|
126
|
+
s->next = 0;
|
|
127
|
+
s->low_prio_state = 0;
|
|
128
|
+
} else {
|
|
129
|
+
us_internal_socket_context_unlink_socket(s->context, s);
|
|
130
|
+
}
|
|
131
|
+
us_poll_stop((struct us_poll_t *) s, s->context->loop);
|
|
132
|
+
bsd_close_socket(us_poll_fd((struct us_poll_t *) s));
|
|
133
|
+
|
|
134
|
+
/* Link this socket to the close-list and let it be deleted after this iteration */
|
|
135
|
+
s->next = s->context->loop->data.closed_head;
|
|
136
|
+
s->context->loop->data.closed_head = s;
|
|
137
|
+
|
|
138
|
+
/* Any socket with prev = context is marked as closed */
|
|
139
|
+
s->prev = (struct us_socket_t *) s->context;
|
|
140
|
+
|
|
141
|
+
return s->context->on_close(s, code, reason);
|
|
142
|
+
}
|
|
143
|
+
return s;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Not shared with SSL */
|
|
147
|
+
|
|
148
|
+
void *us_socket_get_native_handle(int ssl, struct us_socket_t *s) {
|
|
149
|
+
#ifndef LIBUS_NO_SSL
|
|
150
|
+
if (ssl) {
|
|
151
|
+
return us_internal_ssl_socket_get_native_handle((struct us_internal_ssl_socket_t *) s);
|
|
152
|
+
}
|
|
153
|
+
#endif
|
|
154
|
+
|
|
155
|
+
return (void *) (uintptr_t) us_poll_fd((struct us_poll_t *) s);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* This is not available for SSL sockets as it makes no sense. */
|
|
159
|
+
int us_socket_write2(int ssl, struct us_socket_t *s, const char *header, int header_length, const char *payload, int payload_length) {
|
|
160
|
+
|
|
161
|
+
if (us_socket_is_closed(ssl, s) || us_socket_is_shut_down(ssl, s)) {
|
|
162
|
+
return 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
int written = bsd_write2(us_poll_fd(&s->p), header, header_length, payload, payload_length);
|
|
166
|
+
if (written != header_length + payload_length) {
|
|
167
|
+
us_poll_change(&s->p, s->context->loop, LIBUS_SOCKET_READABLE | LIBUS_SOCKET_WRITABLE);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return written < 0 ? 0 : written;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
int us_socket_write(int ssl, struct us_socket_t *s, const char *data, int length, int msg_more) {
|
|
174
|
+
#ifndef LIBUS_NO_SSL
|
|
175
|
+
if (ssl) {
|
|
176
|
+
return us_internal_ssl_socket_write((struct us_internal_ssl_socket_t *) s, data, length, msg_more);
|
|
177
|
+
}
|
|
178
|
+
#endif
|
|
179
|
+
|
|
180
|
+
if (us_socket_is_closed(ssl, s) || us_socket_is_shut_down(ssl, s)) {
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
int written = bsd_send(us_poll_fd(&s->p), data, length, msg_more);
|
|
185
|
+
if (written != length) {
|
|
186
|
+
s->context->loop->data.last_write_failed = 1;
|
|
187
|
+
us_poll_change(&s->p, s->context->loop, LIBUS_SOCKET_READABLE | LIBUS_SOCKET_WRITABLE);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return written < 0 ? 0 : written;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
void *us_socket_ext(int ssl, struct us_socket_t *s) {
|
|
194
|
+
#ifndef LIBUS_NO_SSL
|
|
195
|
+
if (ssl) {
|
|
196
|
+
return us_internal_ssl_socket_ext((struct us_internal_ssl_socket_t *) s);
|
|
197
|
+
}
|
|
198
|
+
#endif
|
|
199
|
+
|
|
200
|
+
return s + 1;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
int us_socket_is_shut_down(int ssl, struct us_socket_t *s) {
|
|
204
|
+
#ifndef LIBUS_NO_SSL
|
|
205
|
+
if (ssl) {
|
|
206
|
+
return us_internal_ssl_socket_is_shut_down((struct us_internal_ssl_socket_t *) s);
|
|
207
|
+
}
|
|
208
|
+
#endif
|
|
209
|
+
|
|
210
|
+
return us_internal_poll_type(&s->p) == POLL_TYPE_SOCKET_SHUT_DOWN;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
void us_socket_shutdown(int ssl, struct us_socket_t *s) {
|
|
214
|
+
#ifndef LIBUS_NO_SSL
|
|
215
|
+
if (ssl) {
|
|
216
|
+
us_internal_ssl_socket_shutdown((struct us_internal_ssl_socket_t *) s);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
#endif
|
|
220
|
+
|
|
221
|
+
/* Todo: should we emit on_close if calling shutdown on an already half-closed socket?
|
|
222
|
+
* We need more states in that case, we need to track RECEIVED_FIN
|
|
223
|
+
* so far, the app has to track this and call close as needed */
|
|
224
|
+
if (!us_socket_is_closed(ssl, s) && !us_socket_is_shut_down(ssl, s)) {
|
|
225
|
+
us_internal_poll_set_type(&s->p, POLL_TYPE_SOCKET_SHUT_DOWN);
|
|
226
|
+
us_poll_change(&s->p, s->context->loop, us_poll_events(&s->p) & LIBUS_SOCKET_READABLE);
|
|
227
|
+
bsd_shutdown_socket(us_poll_fd((struct us_poll_t *) s));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
#endif
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Authored by Alex Hultman, 2018-2021.
|
|
3
|
+
* Intellectual property of third-party.
|
|
4
|
+
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef LIBUS_USE_IO_URING
|
|
19
|
+
|
|
20
|
+
#include "libusockets.h"
|
|
21
|
+
#include "internal/internal.h"
|
|
22
|
+
|
|
23
|
+
#include <stdio.h>
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
#include <string.h>
|
|
26
|
+
|
|
27
|
+
int us_udp_packet_buffer_ecn(struct us_udp_packet_buffer_t *buf, int index) {
|
|
28
|
+
return bsd_udp_packet_buffer_ecn(buf, index);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
int us_udp_packet_buffer_local_ip(struct us_udp_packet_buffer_t *buf, int index, char *ip) {
|
|
32
|
+
return bsd_udp_packet_buffer_local_ip(buf, index, ip);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
char *us_udp_packet_buffer_peer(struct us_udp_packet_buffer_t *buf, int index) {
|
|
36
|
+
return bsd_udp_packet_buffer_peer(buf, index);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
char *us_udp_packet_buffer_payload(struct us_udp_packet_buffer_t *buf, int index) {
|
|
40
|
+
return bsd_udp_packet_buffer_payload(buf, index);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
int us_udp_packet_buffer_payload_length(struct us_udp_packet_buffer_t *buf, int index) {
|
|
44
|
+
return bsd_udp_packet_buffer_payload_length(buf, index);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// what should we return? number of sent datagrams?
|
|
48
|
+
int us_udp_socket_send(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf, int num) {
|
|
49
|
+
int fd = us_poll_fd((struct us_poll_t *) s);
|
|
50
|
+
|
|
51
|
+
// we need to poll out if we failed
|
|
52
|
+
|
|
53
|
+
return bsd_sendmmsg(fd, buf, num, 0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
int us_udp_socket_receive(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf) {
|
|
57
|
+
int fd = us_poll_fd((struct us_poll_t *) s);
|
|
58
|
+
return bsd_recvmmsg(fd, buf, LIBUS_UDP_MAX_NUM, 0, 0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void us_udp_buffer_set_packet_payload(struct us_udp_packet_buffer_t *send_buf, int index, int offset, void *payload, int length, void *peer_addr) {
|
|
62
|
+
bsd_udp_buffer_set_packet_payload(send_buf, index, offset, payload, length, peer_addr);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
struct us_udp_packet_buffer_t *us_create_udp_packet_buffer() {
|
|
66
|
+
return (struct us_udp_packet_buffer_t *) bsd_create_udp_packet_buffer();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
struct us_internal_udp_t {
|
|
70
|
+
struct us_internal_callback_t cb;
|
|
71
|
+
struct us_udp_packet_buffer_t *receive_buf;
|
|
72
|
+
void (*data_cb)(struct us_udp_socket_t *, struct us_udp_packet_buffer_t *, int);
|
|
73
|
+
void (*drain_cb)(struct us_udp_socket_t *);
|
|
74
|
+
void *user;
|
|
75
|
+
/* An UDP socket can only ever be bound to one single port regardless of how
|
|
76
|
+
* many interfaces it may listen to. Therefore we cache the port after creation
|
|
77
|
+
* and use it to build a proper and full sockaddr_in or sockaddr_in6 for every received packet */
|
|
78
|
+
int port;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
int us_udp_socket_bound_port(struct us_udp_socket_t *s) {
|
|
82
|
+
return ((struct us_internal_udp_t *) s)->port;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Internal wrapper, move from here */
|
|
86
|
+
void internal_on_udp_read(struct us_udp_socket_t *s) {
|
|
87
|
+
|
|
88
|
+
// lookup receive buffer and callback here
|
|
89
|
+
struct us_internal_udp_t *udp = (struct us_internal_udp_t *) s;
|
|
90
|
+
|
|
91
|
+
int packets = us_udp_socket_receive(s, udp->receive_buf);
|
|
92
|
+
//printf("Packets: %d\n", packets);
|
|
93
|
+
|
|
94
|
+
// we need to get the socket data and lookup its callback here
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
udp->data_cb(s, udp->receive_buf, packets);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void *us_udp_socket_user(struct us_udp_socket_t *s) {
|
|
101
|
+
struct us_internal_udp_t *udp = (struct us_internal_udp_t *) s;
|
|
102
|
+
|
|
103
|
+
return udp->user;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, struct us_udp_packet_buffer_t *buf, void (*data_cb)(struct us_udp_socket_t *, struct us_udp_packet_buffer_t *, int), void (*drain_cb)(struct us_udp_socket_t *), const char *host, unsigned short port, void *user) {
|
|
107
|
+
|
|
108
|
+
LIBUS_SOCKET_DESCRIPTOR fd = bsd_create_udp_socket(host, port);
|
|
109
|
+
if (fd == LIBUS_SOCKET_ERROR) {
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* If buf is 0 then create one here */
|
|
114
|
+
if (!buf) {
|
|
115
|
+
buf = us_create_udp_packet_buffer();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
int ext_size = 0;
|
|
119
|
+
int fallthrough = 0;
|
|
120
|
+
|
|
121
|
+
struct us_poll_t *p = us_create_poll(loop, fallthrough, sizeof(struct us_internal_udp_t) + ext_size);
|
|
122
|
+
us_poll_init(p, fd, POLL_TYPE_CALLBACK);
|
|
123
|
+
|
|
124
|
+
struct us_internal_udp_t *cb = (struct us_internal_udp_t *) p;
|
|
125
|
+
cb->cb.loop = loop;
|
|
126
|
+
cb->cb.cb_expects_the_loop = 0;
|
|
127
|
+
cb->cb.leave_poll_ready = 1;
|
|
128
|
+
|
|
129
|
+
/* Get and store the port once */
|
|
130
|
+
struct bsd_addr_t tmp;
|
|
131
|
+
bsd_local_addr(fd, &tmp);
|
|
132
|
+
cb->port = bsd_addr_get_port(&tmp);
|
|
133
|
+
|
|
134
|
+
printf("The port of UDP is: %d\n", cb->port);
|
|
135
|
+
|
|
136
|
+
/* There is no udp socket context, only user data */
|
|
137
|
+
/* This should really be ext like everything else */
|
|
138
|
+
cb->user = user;
|
|
139
|
+
|
|
140
|
+
cb->data_cb = data_cb;
|
|
141
|
+
cb->receive_buf = buf;
|
|
142
|
+
cb->drain_cb = drain_cb;
|
|
143
|
+
|
|
144
|
+
cb->cb.cb = (void (*)(struct us_internal_callback_t *)) internal_on_udp_read;
|
|
145
|
+
|
|
146
|
+
us_poll_start((struct us_poll_t *) cb, cb->cb.loop, LIBUS_SOCKET_READABLE);
|
|
147
|
+
|
|
148
|
+
return (struct us_udp_socket_t *) cb;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#endif
|