Update UDPConnection to use updated HashMap
This commit is contained in:
parent
40f4df0fba
commit
84791a5399
2 changed files with 17 additions and 17 deletions
|
@ -152,7 +152,7 @@ void UDPC_destroy(UDPC_Context *ctx)
|
||||||
free(ctx);
|
free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPC_INTERNAL_destroy_conMap(void *unused, char *data)
|
void UDPC_INTERNAL_destroy_conMap(void *unused, uint32_t addr, char *data)
|
||||||
{
|
{
|
||||||
UDPC_INTERNAL_ConnectionData *cd = (UDPC_INTERNAL_ConnectionData*)data;
|
UDPC_INTERNAL_ConnectionData *cd = (UDPC_INTERNAL_ConnectionData*)data;
|
||||||
for(int x = 0; x * sizeof(UDPC_INTERNAL_PacketInfo) < cd->sentPkts->size; ++x)
|
for(int x = 0; x * sizeof(UDPC_INTERNAL_PacketInfo) < cd->sentPkts->size; ++x)
|
||||||
|
@ -352,7 +352,7 @@ void UDPC_update(UDPC_Context *ctx)
|
||||||
// TODO rest of received packet actions
|
// TODO rest of received packet actions
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPC_INTERNAL_update_to_rtt_si(void *userData, char *data)
|
void UDPC_INTERNAL_update_to_rtt_si(void *userData, uint32_t addr, char *data)
|
||||||
{
|
{
|
||||||
UDPC_INTERNAL_update_struct *us =
|
UDPC_INTERNAL_update_struct *us =
|
||||||
(UDPC_INTERNAL_update_struct*)userData;
|
(UDPC_INTERNAL_update_struct*)userData;
|
||||||
|
@ -361,9 +361,9 @@ void UDPC_INTERNAL_update_to_rtt_si(void *userData, char *data)
|
||||||
// check for timed out connection
|
// check for timed out connection
|
||||||
if(UDPC_ts_diff_to_seconds(&us->tsNow, &cd->received) >= UDPC_TIMEOUT_SECONDS)
|
if(UDPC_ts_diff_to_seconds(&us->tsNow, &cd->received) >= UDPC_TIMEOUT_SECONDS)
|
||||||
{
|
{
|
||||||
UDPC_Deque_push_back(us->removedQueue, &cd->addr, 4);
|
UDPC_Deque_push_back(us->removedQueue, &addr, 4);
|
||||||
UDPC_INTERNAL_log(us->ctx, 2, "Connection timed out with addr %s port %d",
|
UDPC_INTERNAL_log(us->ctx, 2, "Connection timed out with addr %s port %d",
|
||||||
UDPC_INTERNAL_atostr(us->ctx, cd->addr),
|
UDPC_INTERNAL_atostr(us->ctx, addr),
|
||||||
cd->port);
|
cd->port);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ void UDPC_INTERNAL_update_to_rtt_si(void *userData, char *data)
|
||||||
{
|
{
|
||||||
// good mode, bad rtt
|
// good mode, bad rtt
|
||||||
UDPC_INTERNAL_log(us->ctx, 2, "Connection with %s switching to bad mode",
|
UDPC_INTERNAL_log(us->ctx, 2, "Connection with %s switching to bad mode",
|
||||||
UDPC_INTERNAL_atostr(us->ctx, cd->addr));
|
UDPC_INTERNAL_atostr(us->ctx, addr));
|
||||||
|
|
||||||
cd->flags = cd->flags & 0xFFFFFFFD;
|
cd->flags = cd->flags & 0xFFFFFFFD;
|
||||||
if(cd->toggledTimer <= 10.0f)
|
if(cd->toggledTimer <= 10.0f)
|
||||||
|
@ -409,7 +409,7 @@ void UDPC_INTERNAL_update_to_rtt_si(void *userData, char *data)
|
||||||
cd->toggleTimer = 0.0f;
|
cd->toggleTimer = 0.0f;
|
||||||
cd->toggledTimer = 0.0f;
|
cd->toggledTimer = 0.0f;
|
||||||
UDPC_INTERNAL_log(us->ctx, 2, "Connection with %s switching to good mode",
|
UDPC_INTERNAL_log(us->ctx, 2, "Connection with %s switching to good mode",
|
||||||
UDPC_INTERNAL_atostr(us->ctx, cd->addr));
|
UDPC_INTERNAL_atostr(us->ctx, addr));
|
||||||
cd->flags |= 0x2;
|
cd->flags |= 0x2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ void UDPC_INTERNAL_update_to_rtt_si(void *userData, char *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPC_INTERNAL_update_send(void *userData, char *data)
|
void UDPC_INTERNAL_update_send(void *userData, uint32_t addr, char *data)
|
||||||
{
|
{
|
||||||
UDPC_INTERNAL_update_struct *us =
|
UDPC_INTERNAL_update_struct *us =
|
||||||
(UDPC_INTERNAL_update_struct*)userData;
|
(UDPC_INTERNAL_update_struct*)userData;
|
||||||
|
@ -454,7 +454,7 @@ void UDPC_INTERNAL_update_send(void *userData, char *data)
|
||||||
|
|
||||||
struct sockaddr_in destinationInfo;
|
struct sockaddr_in destinationInfo;
|
||||||
destinationInfo.sin_family = AF_INET;
|
destinationInfo.sin_family = AF_INET;
|
||||||
destinationInfo.sin_addr.s_addr = cd->addr;
|
destinationInfo.sin_addr.s_addr = addr;
|
||||||
destinationInfo.sin_port = htons(cd->port);
|
destinationInfo.sin_port = htons(cd->port);
|
||||||
long int sentBytes = sendto(
|
long int sentBytes = sendto(
|
||||||
us->ctx->socketHandle,
|
us->ctx->socketHandle,
|
||||||
|
@ -466,13 +466,13 @@ void UDPC_INTERNAL_update_send(void *userData, char *data)
|
||||||
if(sentBytes != 20)
|
if(sentBytes != 20)
|
||||||
{
|
{
|
||||||
UDPC_INTERNAL_log(us->ctx, 0, "Failed to send packet to %s port %d",
|
UDPC_INTERNAL_log(us->ctx, 0, "Failed to send packet to %s port %d",
|
||||||
UDPC_INTERNAL_atostr(us->ctx, cd->addr), cd->port);
|
UDPC_INTERNAL_atostr(us->ctx, addr), cd->port);
|
||||||
free(data);
|
free(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPC_INTERNAL_PacketInfo sentInfo = {
|
UDPC_INTERNAL_PacketInfo sentInfo = {
|
||||||
cd->addr,
|
addr,
|
||||||
cd->lseq - 1,
|
cd->lseq - 1,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -510,7 +510,7 @@ void UDPC_INTERNAL_update_send(void *userData, char *data)
|
||||||
|
|
||||||
struct sockaddr_in destinationInfo;
|
struct sockaddr_in destinationInfo;
|
||||||
destinationInfo.sin_family = AF_INET;
|
destinationInfo.sin_family = AF_INET;
|
||||||
destinationInfo.sin_addr.s_addr = cd->addr;
|
destinationInfo.sin_addr.s_addr = addr;
|
||||||
destinationInfo.sin_port = htons(cd->port);
|
destinationInfo.sin_port = htons(cd->port);
|
||||||
long int sentBytes = sendto(
|
long int sentBytes = sendto(
|
||||||
us->ctx->socketHandle,
|
us->ctx->socketHandle,
|
||||||
|
@ -522,7 +522,7 @@ void UDPC_INTERNAL_update_send(void *userData, char *data)
|
||||||
if(sentBytes != 20 + pinfo->size)
|
if(sentBytes != 20 + pinfo->size)
|
||||||
{
|
{
|
||||||
UDPC_INTERNAL_log(us->ctx, 0, "Failed to send packet to %s port %d",
|
UDPC_INTERNAL_log(us->ctx, 0, "Failed to send packet to %s port %d",
|
||||||
UDPC_INTERNAL_atostr(us->ctx, cd->addr), cd->port);
|
UDPC_INTERNAL_atostr(us->ctx, addr), cd->port);
|
||||||
free(data);
|
free(data);
|
||||||
free(pinfo->data);
|
free(pinfo->data);
|
||||||
UDPC_Deque_pop_front(cd->sendPktQueue, sizeof(UDPC_INTERNAL_PacketInfo));
|
UDPC_Deque_pop_front(cd->sendPktQueue, sizeof(UDPC_INTERNAL_PacketInfo));
|
||||||
|
@ -532,7 +532,7 @@ void UDPC_INTERNAL_update_send(void *userData, char *data)
|
||||||
if((pinfo->flags & 0x2) != 0)
|
if((pinfo->flags & 0x2) != 0)
|
||||||
{
|
{
|
||||||
UDPC_INTERNAL_PacketInfo sentInfo = {
|
UDPC_INTERNAL_PacketInfo sentInfo = {
|
||||||
cd->addr,
|
addr,
|
||||||
cd->lseq - 1,
|
cd->lseq - 1,
|
||||||
0x2,
|
0x2,
|
||||||
data,
|
data,
|
||||||
|
@ -545,7 +545,7 @@ void UDPC_INTERNAL_update_send(void *userData, char *data)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UDPC_INTERNAL_PacketInfo sentInfo = {
|
UDPC_INTERNAL_PacketInfo sentInfo = {
|
||||||
cd->addr,
|
addr,
|
||||||
cd->lseq - 1,
|
cd->lseq - 1,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -109,7 +109,7 @@ UDPC_Context* UDPC_init_threaded_update(uint16_t listenPort, int isClient);
|
||||||
|
|
||||||
void UDPC_destroy(UDPC_Context *ctx);
|
void UDPC_destroy(UDPC_Context *ctx);
|
||||||
|
|
||||||
void UDPC_INTERNAL_destroy_conMap(void *unused, char *data);
|
void UDPC_INTERNAL_destroy_conMap(void *unused, uint32_t addr, char *data);
|
||||||
|
|
||||||
uint32_t UDPC_get_error(UDPC_Context *ctx);
|
uint32_t UDPC_get_error(UDPC_Context *ctx);
|
||||||
|
|
||||||
|
@ -129,9 +129,9 @@ void UDPC_set_logging_type(UDPC_Context *ctx, uint32_t logType);
|
||||||
/// If threaded, this function is called automatically
|
/// If threaded, this function is called automatically
|
||||||
void UDPC_update(UDPC_Context *ctx);
|
void UDPC_update(UDPC_Context *ctx);
|
||||||
|
|
||||||
void UDPC_INTERNAL_update_to_rtt_si(void *userData, char *data);
|
void UDPC_INTERNAL_update_to_rtt_si(void *userData, uint32_t addr, char *data);
|
||||||
|
|
||||||
void UDPC_INTERNAL_update_send(void *userData, char *data);
|
void UDPC_INTERNAL_update_send(void *userData, uint32_t addr, char *data);
|
||||||
|
|
||||||
float UDPC_ts_diff_to_seconds(struct timespec *ts0, struct timespec *ts1);
|
float UDPC_ts_diff_to_seconds(struct timespec *ts0, struct timespec *ts1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue