aboutsummaryrefslogtreecommitdiff
path: root/lib/libostp/param.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libostp/param.c')
-rw-r--r--lib/libostp/param.c16
1 files changed, 8 insertions, 8 deletions
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 <stdio.h>
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);
}