summaryrefslogtreecommitdiff
path: root/cmd/srv9p/gnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/srv9p/gnet.c')
-rw-r--r--cmd/srv9p/gnet.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/cmd/srv9p/gnet.c b/cmd/srv9p/gnet.c
index 92e74c7..d7e8717 100644
--- a/cmd/srv9p/gnet.c
+++ b/cmd/srv9p/gnet.c
@@ -1,4 +1,4 @@
-/* srv9p/gnet.c - libnet implementation for libcr + GNU libc
+/* srv9p/gnet.c - libmisc/net.h implementation for libcr + GNU libc
*
* Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-Licence-Identifier: AGPL-3.0-or-later
@@ -20,6 +20,7 @@
#include <signal.h> /* for siginfo_t, struct sigaction, enum sigval, sigaction(), SIGRTMIN, SIGRTMAX, SA_SIGINFO */
#include <libcr/coroutine.h>
+#include <libmisc/vcall.h>
#include "gnet.h"
@@ -71,16 +72,16 @@ static inline bool RUN_PTHREAD(void *(*fn)(void *), void *args) {
/* init() ( AKA socket(3) + listen(3) )****************************************/
-static struct libnet_conn *gnet_accept(struct libnet_listener *_listener);
-static ssize_t gnet_read(struct libnet_conn *conn, void *buf, size_t count);
-static ssize_t gnet_write(struct libnet_conn *conn, void *buf, size_t count);
-static int gnet_close(struct libnet_conn *conn, bool rd, bool wr);
+static implements_net_conn *gnet_accept(implements_net_listener *_listener);
+static ssize_t gnet_read(implements_net_conn *conn, void *buf, size_t count);
+static ssize_t gnet_write(implements_net_conn *conn, void *buf, size_t count);
+static int gnet_close(implements_net_conn *conn, bool rd, bool wr);
-static struct libnet_listener_vtable gnet_listener_vtable = {
+static struct net_listener_vtable gnet_listener_vtable = {
.accept = gnet_accept,
};
-static struct libnet_conn_vtable gnet_conn_vtable = {
+static struct net_conn_vtable gnet_conn_vtable = {
.read = gnet_read,
.write = gnet_write,
.close = gnet_close,
@@ -131,8 +132,8 @@ static void *_pthread_accept(void *_args) {
return NULL;
};
-static struct libnet_conn *gnet_accept(struct libnet_listener *_listener) {
- struct gnet_listener *listener = (struct gnet_listener *)_listener;
+static implements_net_conn *gnet_accept(implements_net_listener *_listener) {
+ struct gnet_listener *listener = VCALL_SELF(struct gnet_listener, implements_net_listener, _listener);
assert(listener);
int ret_connfd;
@@ -147,7 +148,7 @@ static struct libnet_conn *gnet_accept(struct libnet_listener *_listener) {
listener->active_conn.vtable = &gnet_conn_vtable;
listener->active_conn.fd = ret_connfd;
- return (struct libnet_conn *)&listener->active_conn;
+ return &listener->active_conn;
}
/* read() *********************************************************************/
@@ -172,8 +173,8 @@ static void *_pthread_read(void *_args) {
return NULL;
};
-static ssize_t gnet_read(struct libnet_conn *_conn, void *buf, size_t count) {
- struct _gnet_conn *conn = (struct _gnet_conn *)_conn;
+static ssize_t gnet_read(implements_net_conn *_conn, void *buf, size_t count) {
+ struct _gnet_conn *conn = VCALL_SELF(struct _gnet_conn, implements_net_conn, _conn);
assert(conn);
ssize_t ret;
@@ -222,8 +223,8 @@ static void *_pthread_write(void *_args) {
return NULL;
};
-static ssize_t gnet_write(struct libnet_conn *_conn, void *buf, size_t count) {
- struct _gnet_conn *conn = (struct _gnet_conn *)_conn;
+static ssize_t gnet_write(implements_net_conn *_conn, void *buf, size_t count) {
+ struct _gnet_conn *conn = VCALL_SELF(struct _gnet_conn, implements_net_conn, _conn);
assert(conn);
ssize_t ret;
@@ -244,8 +245,8 @@ static ssize_t gnet_write(struct libnet_conn *_conn, void *buf, size_t count) {
/* close() ********************************************************************/
-static int gnet_close(struct libnet_conn *_conn, bool rd, bool wr) {
- struct _gnet_conn *conn = (struct _gnet_conn *)_conn;
+static int gnet_close(implements_net_conn *_conn, bool rd, bool wr) {
+ struct _gnet_conn *conn = VCALL_SELF(struct _gnet_conn, implements_net_conn, _conn);
assert(conn);
int how;