From 73ead92c2d37d5d091992ef617c4abdfe9907a18 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 29 Sep 2024 22:38:43 -0400 Subject: project: Massive fixups - Fix client handling - Add multithreading - Fixup bad values Signed-off-by: Ian Moffett --- lib/include/libostp/server.h | 17 +++++++++++++---- lib/include/net/auth.h | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'lib/include') diff --git a/lib/include/libostp/server.h b/lib/include/libostp/server.h index a7a737b..0e232f6 100644 --- a/lib/include/libostp/server.h +++ b/lib/include/libostp/server.h @@ -32,23 +32,32 @@ #include #include +#include #include #define MAX_CLIENTS 32 +struct ostp_client { + struct ostp_session session; + int sockfd; + pthread_t td; +}; + struct ostp_listener { - int(*on_recv)(struct ostp_session *session, const char *buf, size_t len); + int(*on_recv)(struct ostp_client *c, const char *buf, size_t len); int port; /* -- Private -- */ - int clients[MAX_CLIENTS]; + struct ostp_client clients[MAX_CLIENTS]; + size_t client_count; int serv_sockfd; fd_set client_fds; }; void listener_init(struct ostp_listener *lp); -int listener_bind(struct ostp_session *sp, struct ostp_listener *lp); -int listener_poll(struct ostp_session *sp, struct ostp_listener *lp); +int listener_bind(struct ostp_listener *lp); +int listener_poll(struct ostp_listener *lp); void listener_cleanup(struct ostp_listener *lp); +void listener_close(struct ostp_listener *lp, struct ostp_client *c); #endif /* !LIBOSTP_SERVER_H_ */ diff --git a/lib/include/net/auth.h b/lib/include/net/auth.h index d672231..0f22d22 100644 --- a/lib/include/net/auth.h +++ b/lib/include/net/auth.h @@ -34,8 +34,8 @@ #include #include -int handle_srq(struct ostp_session *sp, struct ostp_listener *lp, +int handle_srq(struct ostp_client *c, struct ostp_listener *lp, struct session_request *srq); -int negotiate_spw(struct ostp_session *sp, unsigned char *session_key); +int negotiate_spw(struct ostp_client *c, unsigned char *session_key); #endif /* NET_AUTH_H_ */ -- cgit v1.2.3