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/libostp/param.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/libostp/param.c') diff --git a/lib/libostp/param.c b/lib/libostp/param.c index 4c14733..8b83f46 100644 --- a/lib/libostp/param.c +++ b/lib/libostp/param.c @@ -36,9 +36,9 @@ #include static int -handle_pap(struct ostp_session *sp, const struct pap *pap, const unsigned char *session_key) +handle_pap(struct ostp_client *c, const struct pap *pap, const unsigned char *session_key) { - int error = -1; + int error = 0; uint8_t attempts = 0; struct pap tmp_pap = *pap; const size_t LEN = sizeof(struct pap); @@ -48,7 +48,7 @@ handle_pap(struct ostp_session *sp, const struct pap *pap, const unsigned char * /* Quick session request, jump right in! */ if (ISSET(tmp_pap.spw, PAP_SPW_QSR)) { printf("Got QSR, starting session...\n"); - send_frame(sp->sockfd, &tmp_pap, LEN, session_key); + send_frame(c->sockfd, &tmp_pap, LEN, session_key); return 0; } @@ -65,11 +65,11 @@ handle_pap(struct ostp_session *sp, const struct pap *pap, const unsigned char * tmp_pap.code = PAP_BAD_SPW; /* Send in PAP and wait for response */ - if ((error = send_frame(sp->sockfd, &tmp_pap, LEN, session_key)) < -1) { + if ((error = send_frame(c->sockfd, &tmp_pap, LEN, session_key)) < 0) { printf("Failed to send PAP frame\n"); return -1; } - if ((error = recv_frame(sp->sockfd, LEN, session_key, &tmp_pap)) < -1) { + if ((error = recv_frame(c->sockfd, LEN, session_key, &tmp_pap)) < 0) { printf("Failed to recv PAP frame\n"); return error; } @@ -81,16 +81,16 @@ handle_pap(struct ostp_session *sp, const struct pap *pap, const unsigned char * } int -negotiate_spw(struct ostp_session *sp, unsigned char *session_key) +negotiate_spw(struct ostp_client *c, unsigned char *session_key) { const size_t LEN = sizeof(struct pap); struct pap pap; int error; /* Get PAP from the network */ - if ((error = recv_frame(sp->sockfd, LEN, session_key, &pap)) < -1) { + if ((error = recv_frame(c->sockfd, LEN, session_key, &pap)) < 0) { return error; } - return handle_pap(sp, &pap, session_key); + return handle_pap(c, &pap, session_key); } -- cgit v1.2.3