mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 05:23:12 -07:00
Minor Style Fixes
This commit is contained in:
parent
042e02eb3e
commit
49d65ad14a
32 changed files with 248 additions and 304 deletions
|
@ -109,7 +109,6 @@ static const float vert_pos[] = {
|
|||
1.0f, 1.0f
|
||||
};
|
||||
|
||||
|
||||
QSurfaceFormat AVOpenGLWidget::CreateSurfaceFormat()
|
||||
{
|
||||
QSurfaceFormat format;
|
||||
|
|
|
@ -68,7 +68,6 @@ static QSet<QString> chiaki_motion_controller_guids({
|
|||
"030000008f0e00001431000000000000",
|
||||
});
|
||||
|
||||
|
||||
static ControllerManager *instance = nullptr;
|
||||
|
||||
#define UPDATE_INTERVAL_MS 4
|
||||
|
|
|
@ -23,7 +23,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_audio_receiver_init(ChiakiAudioReceiver *au
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT void chiaki_audio_receiver_fini(ChiakiAudioReceiver *audio_receiver)
|
||||
{
|
||||
#ifdef CHIAKI_LIB_ENABLE_OPUS
|
||||
|
@ -32,7 +31,6 @@ CHIAKI_EXPORT void chiaki_audio_receiver_fini(ChiakiAudioReceiver *audio_receive
|
|||
chiaki_mutex_fini(&audio_receiver->mutex);
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT void chiaki_audio_receiver_stream_info(ChiakiAudioReceiver *audio_receiver, ChiakiAudioHeader *audio_header)
|
||||
{
|
||||
chiaki_mutex_lock(&audio_receiver->mutex);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
// Implementations taken from
|
||||
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_size, char *out, size_t out_size)
|
||||
{
|
||||
const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
@ -80,9 +79,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define WHITESPACE 64
|
||||
#define EQUALS 65
|
||||
#define INVALID 66
|
||||
|
@ -132,7 +128,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_decode(const char *in, size_t in_siz
|
|||
*(out++) = (unsigned char)((buf >> 16) & 0xff);
|
||||
*(out++) = (unsigned char)((buf >> 8) & 0xff);
|
||||
*(out++) = (unsigned char)(buf & 0xff);
|
||||
buf = 0; iter = 0;
|
||||
buf = 0;
|
||||
iter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
|
||||
|
||||
#include <chiaki/common.h>
|
||||
#include <chiaki/random.h>
|
||||
#include <chiaki/fec.h>
|
||||
#include <chiaki/random.h>
|
||||
|
||||
#include <galois.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
|
|
|
@ -501,7 +501,6 @@ static void ctrl_enable_optional_features(ChiakiCtrl *ctrl)
|
|||
ctrl_message_send(ctrl, 0x36, pre_enable, 4);
|
||||
}
|
||||
|
||||
|
||||
static void ctrl_message_received_session_id(ChiakiCtrl *ctrl, uint8_t *payload, size_t payload_size)
|
||||
{
|
||||
if(ctrl->session->ctrl_session_id_received)
|
||||
|
@ -676,7 +675,8 @@ static void ctrl_message_received_keyboard_text_change(ChiakiCtrl* ctrl, uint8_t
|
|||
free(buffer);
|
||||
}
|
||||
|
||||
typedef struct ctrl_response_t {
|
||||
typedef struct ctrl_response_t
|
||||
{
|
||||
bool server_type_valid;
|
||||
uint8_t rp_server_type[0x10];
|
||||
bool success;
|
||||
|
@ -742,7 +742,6 @@ static ChiakiErrorCode ctrl_connect(ChiakiCtrl *ctrl)
|
|||
if(err != CHIAKI_ERR_SUCCESS)
|
||||
CHIAKI_LOGE(session->log, "Failed to set ctrl socket to non-blocking: %s", chiaki_error_string(err));
|
||||
|
||||
|
||||
chiaki_mutex_unlock(&ctrl->notif_mutex);
|
||||
err = chiaki_stop_pipe_connect(&ctrl->notif_pipe, sock, sa, addr->ai_addrlen);
|
||||
chiaki_mutex_lock(&ctrl->notif_mutex);
|
||||
|
|
|
@ -79,7 +79,6 @@ CHIAKI_EXPORT void chiaki_ecdh_fini(ChiakiECDH *ecdh)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_set_local_key(ChiakiECDH *ecdh, const uint8_t *private_key, size_t private_key_size, const uint8_t *public_key, size_t public_key_size)
|
||||
{
|
||||
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
|
||||
|
@ -89,24 +88,19 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_set_local_key(ChiakiECDH *ecdh, const
|
|||
|
||||
// public
|
||||
int r = 0;
|
||||
r = mbedtls_ecp_point_read_binary(&ecdh->ctx.grp, &ecdh->ctx.Q,
|
||||
public_key, public_key_size);
|
||||
if(r != 0 ){
|
||||
r = mbedtls_ecp_point_read_binary(&ecdh->ctx.grp, &ecdh->ctx.Q, public_key, public_key_size);
|
||||
if(r != 0)
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
// secret
|
||||
r = mbedtls_mpi_read_binary(&ecdh->ctx.d, private_key, private_key_size);
|
||||
if(r != 0 ){
|
||||
if(r != 0)
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
// regen key
|
||||
r = mbedtls_ecdh_gen_public(&ecdh->ctx.grp, &ecdh->ctx.d,
|
||||
&ecdh->ctx.Q, mbedtls_ctr_drbg_random, &ecdh->drbg);
|
||||
if(r != 0 ){
|
||||
r = mbedtls_ecdh_gen_public(&ecdh->ctx.grp, &ecdh->ctx.d, &ecdh->ctx.Q, mbedtls_ctr_drbg_random, &ecdh->drbg);
|
||||
if(r != 0)
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
#else
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
#define KEY_BUF_CHUNK_SIZE 0x1000
|
||||
|
||||
|
||||
static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index, const uint8_t *handshake_key, const uint8_t *ecdh_secret);
|
||||
|
||||
static void *gkcrypt_thread_func(void *user);
|
||||
|
@ -110,7 +108,6 @@ CHIAKI_EXPORT void chiaki_gkcrypt_fini(ChiakiGKCrypt *gkcrypt)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index, const uint8_t *handshake_key, const uint8_t *ecdh_secret)
|
||||
{
|
||||
uint8_t data[3 + CHIAKI_HANDSHAKE_KEY_SIZE + 2];
|
||||
|
@ -127,22 +124,26 @@ static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index,
|
|||
mbedtls_md_context_t ctx;
|
||||
mbedtls_md_init(&ctx);
|
||||
|
||||
if(mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256) , 1) != 0){
|
||||
if(mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), 1) != 0)
|
||||
{
|
||||
mbedtls_md_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
if(mbedtls_md_hmac_starts(&ctx, ecdh_secret, CHIAKI_ECDH_SECRET_SIZE) != 0){
|
||||
if(mbedtls_md_hmac_starts(&ctx, ecdh_secret, CHIAKI_ECDH_SECRET_SIZE) != 0)
|
||||
{
|
||||
mbedtls_md_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
if(mbedtls_md_hmac_update(&ctx, data, sizeof(data)) != 0){
|
||||
if(mbedtls_md_hmac_update(&ctx, data, sizeof(data)) != 0)
|
||||
{
|
||||
mbedtls_md_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
if(mbedtls_md_hmac_finish(&ctx, hmac) != 0){
|
||||
if(mbedtls_md_hmac_finish(&ctx, hmac) != 0)
|
||||
{
|
||||
mbedtls_md_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
@ -220,7 +221,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gen_key_stream(ChiakiGKCrypt *gkcry
|
|||
mbedtls_aes_context ctx;
|
||||
mbedtls_aes_init(&ctx);
|
||||
|
||||
if(mbedtls_aes_setkey_enc(&ctx, gkcrypt->key_base, 128) != 0){
|
||||
if(mbedtls_aes_setkey_enc(&ctx, gkcrypt->key_base, 128) != 0)
|
||||
{
|
||||
mbedtls_aes_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
@ -248,9 +250,11 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gen_key_stream(ChiakiGKCrypt *gkcry
|
|||
counter_add(cur, gkcrypt->iv, counter_offset++);
|
||||
|
||||
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
|
||||
for(int i=0; i<buf_size; i=i+16){
|
||||
for(int i = 0; i < buf_size; i = i + 16)
|
||||
{
|
||||
// loop over all blocks of 16 bytes (128 bits)
|
||||
if(mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, buf+i, buf+i) != 0){
|
||||
if(mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, buf + i, buf + i) != 0)
|
||||
{
|
||||
mbedtls_aes_free(&ctx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
@ -373,13 +377,15 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gmac(ChiakiGKCrypt *gkcrypt, uint64
|
|||
mbedtls_gcm_context actx;
|
||||
mbedtls_gcm_init(&actx);
|
||||
// set gmac_key 128 bits key
|
||||
if(mbedtls_gcm_setkey(&actx, MBEDTLS_CIPHER_ID_AES, gmac_key, CHIAKI_GKCRYPT_BLOCK_SIZE*8) != 0){
|
||||
if(mbedtls_gcm_setkey(&actx, MBEDTLS_CIPHER_ID_AES, gmac_key, CHIAKI_GKCRYPT_BLOCK_SIZE * 8) != 0)
|
||||
{
|
||||
mbedtls_gcm_free(&actx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
// encrypt without additional data
|
||||
if(mbedtls_gcm_starts(&actx, MBEDTLS_GCM_ENCRYPT, iv, CHIAKI_GKCRYPT_BLOCK_SIZE, NULL, 0) != 0){
|
||||
if(mbedtls_gcm_starts(&actx, MBEDTLS_GCM_ENCRYPT, iv, CHIAKI_GKCRYPT_BLOCK_SIZE, NULL, 0) != 0)
|
||||
{
|
||||
mbedtls_gcm_free(&actx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
@ -389,7 +395,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gmac(ChiakiGKCrypt *gkcrypt, uint64
|
|||
if(mbedtls_gcm_crypt_and_tag(&actx, MBEDTLS_GCM_ENCRYPT,
|
||||
0, iv, CHIAKI_GKCRYPT_BLOCK_SIZE,
|
||||
buf, buf_size, NULL, NULL,
|
||||
CHIAKI_GKCRYPT_GMAC_SIZE, gmac_out) != 0){
|
||||
CHIAKI_GKCRYPT_GMAC_SIZE, gmac_out) != 0)
|
||||
{
|
||||
|
||||
mbedtls_gcm_free(&actx);
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
|
||||
CHIAKI_EXPORT void chiaki_http_header_free(ChiakiHttpHeader *header)
|
||||
{
|
||||
while(header)
|
||||
|
|
|
@ -74,4 +74,3 @@ CHIAKI_EXPORT void chiaki_packet_stats_get(ChiakiPacketStats *stats, bool reset,
|
|||
reset_stats(stats);
|
||||
chiaki_mutex_unlock(&stats->mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,12 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_random_bytes_crypt(uint8_t *buf, size_t buf
|
|||
mbedtls_entropy_init(&entropy);
|
||||
|
||||
mbedtls_ctr_drbg_set_prediction_resistance(&ctr_drbg, MBEDTLS_CTR_DRBG_PR_OFF);
|
||||
if(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *) "RANDOM_GEN", 10 ) != 0 ){
|
||||
if(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *)"RANDOM_GEN", 10) != 0)
|
||||
{
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
if(mbedtls_ctr_drbg_random(&ctr_drbg, buf, buf_size) != 0){
|
||||
if(mbedtls_ctr_drbg_random(&ctr_drbg, buf, buf_size) != 0)
|
||||
{
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,6 @@ static int request_header_format(char *buf, size_t buf_size, size_t payload_size
|
|||
return cur;
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_regist_request_payload_format(ChiakiTarget target, const uint8_t *ambassador, uint8_t *buf, size_t *buf_size, ChiakiRPCrypt *crypt, const char *psn_online_id, const uint8_t *psn_account_id, uint32_t pin)
|
||||
{
|
||||
size_t buf_size_val = *buf_size;
|
||||
|
|
|
@ -1865,7 +1865,6 @@ static const uint8_t *rpcrypt_hmac_key(ChiakiRPCrypt *rpcrypt)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_generate_iv(ChiakiRPCrypt *rpcrypt, uint8_t *iv, uint64_t counter)
|
||||
{
|
||||
|
@ -1968,7 +1967,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_generate_iv(ChiakiRPCrypt *rpcrypt,
|
|||
buf[CHIAKI_RPCRYPT_KEY_SIZE + 6] = (uint8_t)((counter >> 0x08) & 0xff);
|
||||
buf[CHIAKI_RPCRYPT_KEY_SIZE + 7] = (uint8_t)((counter >> 0x00) & 0xff);
|
||||
|
||||
|
||||
uint8_t hmac[32];
|
||||
unsigned int hmac_len = 0;
|
||||
if(!HMAC(EVP_sha256(), hmac_key, CHIAKI_RPCRYPT_KEY_SIZE, buf, sizeof(buf), hmac, &hmac_len))
|
||||
|
|
|
@ -645,7 +645,6 @@ static void senkusha_takion_data(ChiakiSenkusha *senkusha, ChiakiTakionMessageDa
|
|||
senkusha->state_finished = true;
|
||||
chiaki_cond_signal(&senkusha->state_cond);
|
||||
}
|
||||
|
||||
}
|
||||
chiaki_mutex_unlock(&senkusha->state_mutex);
|
||||
}
|
||||
|
@ -878,4 +877,3 @@ static ChiakiErrorCode senkusha_send_data_wait_for_ack(ChiakiSenkusha *senkusha,
|
|||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -540,10 +540,8 @@ quit:
|
|||
#undef QUIT
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct session_response_t {
|
||||
typedef struct session_response_t
|
||||
{
|
||||
uint32_t error_code;
|
||||
const char *nonce;
|
||||
const char *rp_version;
|
||||
|
@ -652,7 +650,6 @@ static ChiakiErrorCode session_thread_request_session(ChiakiSession *session, Ch
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
if(CHIAKI_SOCKET_IS_INVALID(session_sock))
|
||||
{
|
||||
CHIAKI_LOGE(session->log, "Session request connect failed eventually.");
|
||||
|
|
|
@ -27,9 +27,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_stop_pipe_init(ChiakiStopPipe *stop_pipe)
|
|||
int addr_size = sizeof(stop_pipe->addr);
|
||||
|
||||
stop_pipe->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if(stop_pipe->fd < 0){
|
||||
if(stop_pipe->fd < 0)
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
stop_pipe->addr.sin_family = AF_INET;
|
||||
// bind to localhost
|
||||
stop_pipe->addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
|
|
|
@ -56,7 +56,6 @@ static ChiakiErrorCode stream_connection_send_streaminfo_ack(ChiakiStreamConnect
|
|||
static void stream_connection_takion_av(ChiakiStreamConnection *stream_connection, ChiakiTakionAVPacket *packet);
|
||||
static ChiakiErrorCode stream_connection_send_heartbeat(ChiakiStreamConnection *stream_connection);
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_stream_connection_init(ChiakiStreamConnection *stream_connection, ChiakiSession *session)
|
||||
{
|
||||
stream_connection->session = session;
|
||||
|
@ -121,7 +120,6 @@ CHIAKI_EXPORT void chiaki_stream_connection_fini(ChiakiStreamConnection *stream_
|
|||
chiaki_mutex_fini(&stream_connection->state_mutex);
|
||||
}
|
||||
|
||||
|
||||
static bool state_finished_cond_check(void *user)
|
||||
{
|
||||
ChiakiStreamConnection *stream_connection = user;
|
||||
|
@ -399,7 +397,6 @@ static void stream_connection_takion_data_protobuf(ChiakiStreamConnection *strea
|
|||
break;
|
||||
}
|
||||
chiaki_mutex_unlock(&stream_connection->state_mutex);
|
||||
|
||||
}
|
||||
|
||||
static void stream_connection_takion_data_rumble(ChiakiStreamConnection *stream_connection, uint8_t *buf, size_t buf_size)
|
||||
|
@ -640,7 +637,6 @@ static bool pb_decode_resolution(pb_istream_t *stream, const pb_field_t *field,
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void stream_connection_takion_data_expect_streaminfo(ChiakiStreamConnection *stream_connection, uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
tkproto_TakionMessage msg;
|
||||
|
@ -709,8 +705,6 @@ error:
|
|||
chiaki_cond_signal(&stream_connection->state_cond);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool chiaki_pb_encode_zero_encrypted_key(pb_ostream_t *stream, const pb_field_t *field, void *const *arg)
|
||||
{
|
||||
if(!pb_encode_tag_for_field(stream, field))
|
||||
|
@ -867,7 +861,6 @@ static ChiakiErrorCode stream_connection_send_disconnect(ChiakiStreamConnection
|
|||
return err;
|
||||
}
|
||||
|
||||
|
||||
static void stream_connection_takion_av(ChiakiStreamConnection *stream_connection, ChiakiTakionAVPacket *packet)
|
||||
{
|
||||
chiaki_gkcrypt_decrypt(stream_connection->gkcrypt_remote, packet->key_pos + CHIAKI_GKCRYPT_BLOCK_SIZE, packet->data, packet->data_size);
|
||||
|
@ -878,7 +871,6 @@ static void stream_connection_takion_av(ChiakiStreamConnection *stream_connectio
|
|||
chiaki_audio_receiver_av_packet(stream_connection->audio_receiver, packet);
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode stream_connection_send_heartbeat(ChiakiStreamConnection *stream_connection)
|
||||
{
|
||||
tkproto_TakionMessage msg = { 0 };
|
||||
|
|
|
@ -107,7 +107,6 @@ typedef enum takion_chunk_type_t {
|
|||
TAKION_CHUNK_TYPE_COOKIE_ACK = 0xb,
|
||||
} TakionChunkType;
|
||||
|
||||
|
||||
typedef struct takion_message_t
|
||||
{
|
||||
uint32_t tag;
|
||||
|
@ -120,7 +119,6 @@ typedef struct takion_message_t
|
|||
uint8_t *payload;
|
||||
} TakionMessage;
|
||||
|
||||
|
||||
typedef struct takion_message_payload_init_t
|
||||
{
|
||||
uint32_t tag;
|
||||
|
@ -152,14 +150,12 @@ typedef struct
|
|||
uint16_t channel;
|
||||
} TakionDataPacketEntry;
|
||||
|
||||
|
||||
typedef struct chiaki_takion_postponed_packet_t
|
||||
{
|
||||
uint8_t *buf;
|
||||
size_t buf_size;
|
||||
} ChiakiTakionPostponedPacket;
|
||||
|
||||
|
||||
static void *takion_thread_func(void *user);
|
||||
static void takion_handle_packet(ChiakiTakion *takion, uint8_t *buf, size_t buf_size);
|
||||
static ChiakiErrorCode takion_handle_packet_mac(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size);
|
||||
|
@ -603,7 +599,6 @@ static ChiakiErrorCode takion_handshake(ChiakiTakion *takion, uint32_t *seq_num_
|
|||
|
||||
CHIAKI_LOGI(takion->log, "Takion sent init");
|
||||
|
||||
|
||||
// INIT_ACK <-
|
||||
|
||||
TakionMessagePayloadInitAck init_ack_payload;
|
||||
|
@ -626,15 +621,12 @@ static ChiakiErrorCode takion_handshake(ChiakiTakion *takion, uint32_t *seq_num_
|
|||
takion->tag_remote = init_ack_payload.tag;
|
||||
*seq_num_remote_initial = takion->tag_remote; //init_ack_payload.initial_seq_num;
|
||||
|
||||
if(init_ack_payload.outbound_streams == 0 || init_ack_payload.inbound_streams == 0
|
||||
|| init_ack_payload.outbound_streams > TAKION_INBOUND_STREAMS
|
||||
|| init_ack_payload.inbound_streams < TAKION_OUTBOUND_STREAMS)
|
||||
if(init_ack_payload.outbound_streams == 0 || init_ack_payload.inbound_streams == 0 || init_ack_payload.outbound_streams > TAKION_INBOUND_STREAMS || init_ack_payload.inbound_streams < TAKION_OUTBOUND_STREAMS)
|
||||
{
|
||||
CHIAKI_LOGE(takion->log, "Takion min/max check failed");
|
||||
return CHIAKI_ERR_INVALID_RESPONSE;
|
||||
}
|
||||
|
||||
|
||||
// COOKIE ->
|
||||
|
||||
err = takion_send_message_cookie(takion, init_ack_payload.cookie);
|
||||
|
@ -780,7 +772,6 @@ beach:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_recv(ChiakiTakion *takion, uint8_t *buf, size_t *buf_size, uint64_t timeout_ms)
|
||||
{
|
||||
ChiakiErrorCode err = chiaki_stop_pipe_select_single(&takion->stop_pipe, takion->sock, false, timeout_ms);
|
||||
|
@ -805,7 +796,6 @@ static ChiakiErrorCode takion_recv(ChiakiTakion *takion, uint8_t *buf, size_t *b
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_handle_packet_mac(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
if(!takion->gkcrypt_remote)
|
||||
|
@ -866,7 +856,6 @@ static void takion_postpone_packet(ChiakiTakion *takion, uint8_t *buf, size_t bu
|
|||
packet->buf_size = buf_size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param buf ownership of this buf is taken.
|
||||
*/
|
||||
|
@ -934,7 +923,6 @@ static void takion_handle_packet_message(ChiakiTakion *takion, uint8_t *buf, siz
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void takion_flush_data_queue(ChiakiTakion *takion)
|
||||
{
|
||||
uint64_t seq_num = 0;
|
||||
|
@ -1104,7 +1092,6 @@ static ChiakiErrorCode takion_parse_message(ChiakiTakion *takion, uint8_t *buf,
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_send_message_init(ChiakiTakion *takion, TakionMessagePayloadInit *payload)
|
||||
{
|
||||
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + 0x10];
|
||||
|
@ -1121,8 +1108,6 @@ static ChiakiErrorCode takion_send_message_init(ChiakiTakion *takion, TakionMess
|
|||
return chiaki_takion_send_raw(takion, message, sizeof(message));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_send_message_cookie(ChiakiTakion *takion, uint8_t *cookie)
|
||||
{
|
||||
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + TAKION_COOKIE_SIZE];
|
||||
|
@ -1132,8 +1117,6 @@ static ChiakiErrorCode takion_send_message_cookie(ChiakiTakion *takion, uint8_t
|
|||
return chiaki_takion_send_raw(takion, message, sizeof(message));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_recv_message_init_ack(ChiakiTakion *takion, TakionMessagePayloadInitAck *payload)
|
||||
{
|
||||
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + 0x10 + TAKION_COOKIE_SIZE];
|
||||
|
@ -1181,7 +1164,6 @@ static ChiakiErrorCode takion_recv_message_init_ack(ChiakiTakion *takion, Takion
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static ChiakiErrorCode takion_recv_message_cookie_ack(ChiakiTakion *takion)
|
||||
{
|
||||
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE];
|
||||
|
@ -1221,7 +1203,6 @@ static ChiakiErrorCode takion_recv_message_cookie_ack(ChiakiTakion *takion)
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void takion_handle_packet_av(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
// HHIxIIx
|
||||
|
@ -1453,5 +1434,4 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_v7_av_packet_parse(ChiakiTakionAVPac
|
|||
packet->data_size = buf_size;
|
||||
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ static DWORD WINAPI win32_thread_func(LPVOID param)
|
|||
#endif
|
||||
|
||||
#ifdef __SWITCH__
|
||||
int64_t get_thread_limit(){
|
||||
int64_t get_thread_limit()
|
||||
{
|
||||
uint64_t resource_limit_handle_value = INVALID_HANDLE;
|
||||
svcGetInfo(&resource_limit_handle_value, InfoType_ResourceLimit, INVALID_HANDLE, 0);
|
||||
int64_t thread_cur_value = 0, thread_lim_value = 0;
|
||||
|
@ -45,9 +46,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_thread_create(ChiakiThread *thread, ChiakiT
|
|||
return CHIAKI_ERR_THREAD;
|
||||
#else
|
||||
#ifdef __SWITCH__
|
||||
if(get_thread_limit() <= 1){
|
||||
if(get_thread_limit() <= 1)
|
||||
return CHIAKI_ERR_THREAD;
|
||||
}
|
||||
#endif
|
||||
int r = pthread_create(&thread->thread, NULL, func, arg);
|
||||
if(r != 0)
|
||||
|
@ -90,13 +90,13 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_thread_set_name(ChiakiThread *thread, const
|
|||
if(r != 0)
|
||||
return CHIAKI_ERR_THREAD;
|
||||
#else
|
||||
(void)thread; (void)name;
|
||||
(void)thread;
|
||||
(void)name;
|
||||
#endif
|
||||
#endif
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_mutex_init(ChiakiMutex *mutex, bool rec)
|
||||
{
|
||||
#if _WIN32
|
||||
|
@ -172,9 +172,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_mutex_unlock(ChiakiMutex *mutex)
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_init(ChiakiCond *cond)
|
||||
{
|
||||
#if _WIN32
|
||||
|
@ -214,8 +211,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_fini(ChiakiCond *cond)
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_wait(ChiakiCond *cond, ChiakiMutex *mutex)
|
||||
{
|
||||
#if _WIN32
|
||||
|
@ -323,7 +318,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_timedwait_pred(ChiakiCond *cond, Chiak
|
|||
#endif
|
||||
}
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_signal(ChiakiCond *cond)
|
||||
|
@ -350,9 +344,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_broadcast(ChiakiCond *cond)
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_init(ChiakiBoolPredCond *cond)
|
||||
{
|
||||
cond->pred = false;
|
||||
|
@ -384,7 +375,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_fini(ChiakiBoolPredCond *con
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_lock(ChiakiBoolPredCond *cond)
|
||||
{
|
||||
return chiaki_mutex_lock(&cond->mutex);
|
||||
|
|
|
@ -598,5 +598,3 @@ void Settings::SetCPUOverclock(Host * host, std::string value)
|
|||
this->SetCPUOverclock(host, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue