From 537fef9e8a06a278e181d868f71dd2244239561c Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 12 Mar 2019 14:28:28 +0900 Subject: [PATCH] Fix prepare_pkt function --- src/UDPConnection.c | 30 +++++++++++------------------- src/UDPConnection.h | 1 + 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/UDPConnection.c b/src/UDPConnection.c index fecacda..969e4c3 100644 --- a/src/UDPConnection.c +++ b/src/UDPConnection.c @@ -940,11 +940,11 @@ void UDPC_INTERNAL_update_send(void *userData, uint32_t addr, char *data) UDPC_INTERNAL_prepare_pkt( data, us->ctx->protocolID, - UDPC_ID_CONNECT, + 0, 0, 0xFFFFFFFF, NULL, - 0); + 0x8); struct sockaddr_in destinationInfo; destinationInfo.sin_family = AF_INET; @@ -976,11 +976,11 @@ void UDPC_INTERNAL_update_send(void *userData, uint32_t addr, char *data) UDPC_INTERNAL_prepare_pkt( data, us->ctx->protocolID, - UDPC_ID_CONNECT | cd->id, + cd->id, cd->rseq, cd->ack, &cd->lseq, - 0); + 0x8); struct sockaddr_in destinationInfo; destinationInfo.sin_family = AF_INET; @@ -1362,21 +1362,13 @@ void UDPC_INTERNAL_prepare_pkt( temp = htonl(protocolID); memcpy(d, &temp, 4); - if((flags & 0x4) == 0) - { - temp = htonl(conID | UDPC_ID_NO_REC_CHK); - memcpy(&d[4], &temp, 4); - } - else if((flags & 0x1) != 0) - { - temp = htonl(conID | UDPC_ID_PING); - memcpy(&d[4], &temp, 4); - } - else - { - temp = htonl(conID | ((flags & 0x2) != 0 ? UDPC_ID_RESENDING : 0)); - memcpy(&d[4], &temp, 4); - } + + temp = htonl(conID + | ((flags & 0x1) != 0 ? UDPC_ID_PING : 0) + | ((flags & 0x2) != 0 ? UDPC_ID_RESENDING : 0) + | ((flags & 0x4) == 0 ? UDPC_ID_NO_REC_CHK : 0) + | ((flags & 0x8) != 0 ? UDPC_ID_CONNECT : 0)); + memcpy(&d[4], &temp, 4); if(seqID) { diff --git a/src/UDPConnection.h b/src/UDPConnection.h index 466d77d..eafb066 100644 --- a/src/UDPConnection.h +++ b/src/UDPConnection.h @@ -286,6 +286,7 @@ int UDPC_INTERNAL_threadfn(void *context); * 0x1 - is ping * 0x2 - is resending * 0x4 - is checked received packet + * 0x8 - is init connection packet */ void UDPC_INTERNAL_prepare_pkt( void *data,