Skip to content

Commit

Permalink
Convert several variables held in structs to bool to reflect their ac…
Browse files Browse the repository at this point in the history
…tual usage
  • Loading branch information
jonesmz committed Jan 30, 2024
1 parent 88e0246 commit 5d371d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
20 changes: 11 additions & 9 deletions src/apps/uclient/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "apputils.h"
#include "stun_buffer.h"

#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -54,11 +55,11 @@ typedef enum { UR_STATE_UNKNOWN = 0, UR_STATE_READY, UR_STATE_DONE } UR_STATE;

typedef struct {
/* RFC 6062 */
uint32_t cid;
uint32_t cid; // https://datatracker.ietf.org/doc/html/rfc6062#section-6.2.1
ioa_addr tcp_data_local_addr;
ioa_socket_raw tcp_data_fd;
SSL *tcp_data_ssl;
int tcp_data_bound;
bool tcp_data_bound;
} app_tcp_conn_info;

typedef struct {
Expand All @@ -71,30 +72,31 @@ typedef struct {
ioa_addr relay_addr;
ioa_socket_raw fd;
SSL *ssl;
int broken;
bool broken;
uint8_t nonce[STUN_MAX_NONCE_SIZE + 1];
uint8_t realm[STUN_MAX_REALM_SIZE + 1];
/* oAuth */
int oauth;
int oauth; // Cannot (yet) be converted to bool, as many functions take an int* instead of bool*, those must be
// addressed first.
uint8_t server_name[STUN_MAX_SERVER_NAME_SIZE + 1];
hmackey_t key;
int key_set;
int cok;
bool key_set;
int cok; // presumably means "client oauth key" or something like it? Appears to be used as an index into an array.
/* RFC 6062 */
app_tcp_conn_info **tcp_conn;
size_t tcp_conn_number;
int is_peer;
bool is_peer;
char s_mobile_id[33];
} app_ur_conn_info;

typedef struct {
app_ur_conn_info pinfo;
UR_STATE state;
unsigned int ctime;
unsigned int ctime; // assigned to from a uint64_t variable "current time" likely should be a time_t or similar.
uint16_t chnum;
int wait_cycles;
int timer_cycle;
int completed;
int completed; // A count of the number of connections considered complete.
struct event *input_ev;
struct event *input_tcp_data_ev;
stun_buffer in_buffer;
Expand Down
6 changes: 4 additions & 2 deletions src/apps/uclient/startuclient.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (C) 2011, 2012, 2013 Citrix Systems
*
* All rights reserved.
Expand Down Expand Up @@ -1219,7 +1221,7 @@ int start_c2c_connection(uint16_t clnet_remote_port0, const char *remote_address
}

if (passive_tcp) {
clnet_info2->is_peer = 1;
clnet_info2->is_peer = true;
}

if (clnet_connect(clnet_remote_port, remote_address, ifname, local_address, verbose, clnet_info2) < 0) {
Expand Down Expand Up @@ -1547,7 +1549,7 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a
if (verbose) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "success\n");
}
atc->tcp_data_bound = 1;
atc->tcp_data_bound = true;
} else if (stun_is_challenge_response_str(response_message.buf, (size_t)response_message.len, &err_code,
err_msg, sizeof(err_msg), clnet_info->realm, clnet_info->nonce,
clnet_info->server_name, &(clnet_info->oauth))) {
Expand Down
10 changes: 6 additions & 4 deletions src/apps/uclient/uclient.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (C) 2011, 2012, 2013 Citrix Systems
*
* All rights reserved.
Expand Down Expand Up @@ -265,7 +267,7 @@ int send_buffer(app_ur_conn_info *clnet_info, stun_buffer *message, int data_con
}
/* Falls through. */
default:
clnet_info->broken = 1;
clnet_info->broken = true;
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Unexpected error while writing!\n");
return -1;
}
Expand Down Expand Up @@ -468,7 +470,7 @@ int recv_buffer(app_ur_conn_info *clnet_info, stun_buffer *message, int sync, in
}
/* Falls through. */
default:
clnet_info->broken = 1;
clnet_info->broken = true;
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Unexpected error while reading: rc=%d, sslerr=%d\n", rc, sslerr);
return -1;
}
Expand Down Expand Up @@ -537,7 +539,7 @@ int recv_buffer(app_ur_conn_info *clnet_info, stun_buffer *message, int sync, in
}
/* Falls through. */
default:
clnet_info->broken = 1;
clnet_info->broken = true;
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Unexpected error while reading: rc=%d, sslerr=%d\n", rc, sslerr);
return -1;
}
Expand Down Expand Up @@ -1646,7 +1648,7 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message) {
(const uint8_t *)etoken.token, (int)etoken.size);

memcpy(clnet_info->key, otoken.enc_block.mac_key, otoken.enc_block.key_length);
clnet_info->key_set = 1;
clnet_info->key_set = true;
}

if (stun_attr_add_integrity_by_key_str(message->buf, (size_t *)&(message->len), (uint8_t *)okey_array[cok].kid,
Expand Down

0 comments on commit 5d371d0

Please sign in to comment.