diff --git a/android/crt/src/main/java/software/amazon/awssdk/crt/io/TlsAndroidPrivateKeyOperationHandler.java b/android/crt/src/main/java/software/amazon/awssdk/crt/io/TlsAndroidPrivateKeyOperationHandler.java new file mode 100644 index 000000000..44d42198f --- /dev/null +++ b/android/crt/src/main/java/software/amazon/awssdk/crt/io/TlsAndroidPrivateKeyOperationHandler.java @@ -0,0 +1,105 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +package software.amazon.awssdk.crt.io; + +import java.security.PrivateKey; +import java.security.Signature; +import java.io.ByteArrayOutputStream; + +/* + * TlsKeyOperationHandler implementation for using an Android PrivateKey on TlsKeyOperations + */ +public class TlsAndroidPrivateKeyOperationHandler implements TlsKeyOperationHandler { + private PrivateKey privateKey; + + /* + * DER encoded DigestInfo value to be prefixed to the hash, used for RSA signing + * See https://tools.ietf.org/html/rfc3447#page-43 + */ + static byte[] sha1PrefixToRsaSig = { (byte)0x30, (byte)0x21, (byte)0x30, (byte)0x09, (byte)0x06, (byte)0x05, (byte)0x2b, (byte)0x0e, (byte)0x03, (byte)0x02, (byte)0x1a, (byte)0x05, (byte)0x00, (byte)0x04, (byte)0x14 }; + static byte[] sha224PrefixToRsaSig = { (byte)0x30, (byte)0x2d, (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x60, (byte)0x86, (byte)0x48, (byte)0x01, (byte)0x65, (byte)0x03, (byte)0x04, (byte)0x02, (byte)0x04, (byte)0x05, (byte)0x00, (byte)0x04, (byte)0x1c }; + static byte[] sha256PrefixToRsaSig = { (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x60, (byte)0x86, (byte)0x48, (byte)0x01, (byte)0x65, (byte)0x03, (byte)0x04, (byte)0x02, (byte)0x01, (byte)0x05, (byte)0x00, (byte)0x04, (byte)0x20 }; + static byte[] sha384PrefixToRsaSig = { (byte)0x30, (byte)0x41, (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x60, (byte)0x86, (byte)0x48, (byte)0x01, (byte)0x65, (byte)0x03, (byte)0x04, (byte)0x02, (byte)0x02, (byte)0x05, (byte)0x00, (byte)0x04, (byte)0x30 }; + static byte[] sha512PrefixToRsaSig = { (byte)0x30, (byte)0x51, (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x60, (byte)0x86, (byte)0x48, (byte)0x01, (byte)0x65, (byte)0x03, (byte)0x04, (byte)0x02, (byte)0x03, (byte)0x05, (byte)0x00, (byte)0x04, (byte)0x40 }; + + public TlsAndroidPrivateKeyOperationHandler(PrivateKey privateKey) { + this.privateKey = privateKey; + } + + public void performOperation(TlsKeyOperation operation){ + try{ + if (operation.getType() != TlsKeyOperation.Type.SIGN) { + operation.completeExceptionally(new Throwable("Android KeyChain PrivateKey only handles SIGN operations.")); + return; + } + + // A SIGN operation's inputData is the 32bytes of the SHA-256 digest. + // Before doing the RSA signature, we need to construct a PKCS1 v1.5 DigestInfo. + // See https://datatracker.ietf.org/doc/html/rfc3447#section-9.2 + byte[] dataToSign = operation.getInput(); + + Signature signature = Signature.getInstance("NONEwith" + operation.getSignatureAlgorithm().name());; + + switch(operation.getSignatureAlgorithm()){ + case RSA: + /* + * DER encoded DigestInfo value to be prefixed to the hash, used for RSA signing + * See https://tools.ietf.org/html/rfc3447#page-43 + */ + byte[] digestAlgorithm; + switch(operation.getDigestAlgorithm()){ + case SHA1: + digestAlgorithm = sha1PrefixToRsaSig; + break; + case SHA224: + digestAlgorithm = sha224PrefixToRsaSig; + break; + case SHA256: + digestAlgorithm = sha256PrefixToRsaSig; + break; + case SHA384: + digestAlgorithm = sha384PrefixToRsaSig; + break; + case SHA512: + digestAlgorithm = sha512PrefixToRsaSig; + break; + case UNKNOWN: + default: + operation.completeExceptionally(new Throwable("An UNKNOWN digest algorithm was encountered during a SIGN operation against an Android KeyChain PrivateKey.")); + return; + } + + ByteArrayOutputStream digestInfoStream = new ByteArrayOutputStream(); + digestInfoStream.write(digestAlgorithm); + digestInfoStream.write(dataToSign); + byte[] digestInfo = digestInfoStream.toByteArray(); + + signature.initSign(privateKey); + signature.update(digestInfo); + byte[] signatureBytesRSA = signature.sign(); + + operation.complete(signatureBytesRSA); + return; + + case ECDSA: + + signature.initSign(privateKey); + signature.update(dataToSign); + byte[] signatureBytesECC = signature.sign(); + + operation.complete(signatureBytesECC); + return; + + case UNKNOWN: + default: + + operation.completeExceptionally(new Throwable("An UNKNOWN signature algorithm was encountered during a SIGN operation against an Android KeyChain PrivateKey.")); + return; + } + } catch (Exception ex){ + operation.completeExceptionally(new Throwable("Exception caught during Android KeyChain PrivateKey operation.", ex)); + } + } +} \ No newline at end of file diff --git a/src/main/java/software/amazon/awssdk/crt/Log.java b/src/main/java/software/amazon/awssdk/crt/Log.java index af9c57a74..bc77456c1 100644 --- a/src/main/java/software/amazon/awssdk/crt/Log.java +++ b/src/main/java/software/amazon/awssdk/crt/Log.java @@ -103,7 +103,8 @@ public enum LogSubject { // aws-crt-java, we're authoritative JavaCrtGeneral(0x2400), JavaCrtResource(0x2401), - JavaCrtS3(0x2402) + JavaCrtS3(0x2402), + JavaAndroidKeychain(0x2403) ; LogSubject(int value) { diff --git a/src/main/java/software/amazon/awssdk/crt/io/TlsContextCustomKeyOperationOptions.java b/src/main/java/software/amazon/awssdk/crt/io/TlsContextCustomKeyOperationOptions.java index bf09e4999..7a0b40392 100644 --- a/src/main/java/software/amazon/awssdk/crt/io/TlsContextCustomKeyOperationOptions.java +++ b/src/main/java/software/amazon/awssdk/crt/io/TlsContextCustomKeyOperationOptions.java @@ -51,7 +51,7 @@ public TlsContextCustomKeyOperationOptions withCertificateFileContents(String co } /** - * Returns the path to the X.509 certificate file on desk if it has been set. + * Returns the path to the X.509 certificate file on disk if it has been set. * * @return The path to the certificate file */ diff --git a/src/native/crt.c b/src/native/crt.c index a7bfe79f2..e9cec38f2 100644 --- a/src/native/crt.c +++ b/src/native/crt.c @@ -484,6 +484,8 @@ static struct aws_log_subject_info s_crt_log_subject_infos[] = { AWS_LS_JAVA_CRT_RESOURCE, "JavaCrtResource", "Subject for CrtResource"), DEFINE_LOG_SUBJECT_INFO( AWS_LS_JAVA_CRT_S3, "JavaCrtS3", "Subject for the layer binding aws-c-s3 to Java"), + DEFINE_LOG_SUBJECT_INFO( + AWS_LS_JAVA_ANDROID_KEYCHAIN, "android-keychain", "Subject for Android KeyChain"), /* clang-format on */ }; diff --git a/src/native/crt.h b/src/native/crt.h index 817aa6b5f..67c740c05 100644 --- a/src/native/crt.h +++ b/src/native/crt.h @@ -19,6 +19,7 @@ enum aws_java_crt_log_subject { AWS_LS_JAVA_CRT_GENERAL = AWS_LOG_SUBJECT_BEGIN_RANGE(AWS_CRT_JAVA_PACKAGE_ID), AWS_LS_JAVA_CRT_RESOURCE, AWS_LS_JAVA_CRT_S3, + AWS_LS_JAVA_ANDROID_KEYCHAIN, AWS_LS_JAVA_CRT_LAST = AWS_LOG_SUBJECT_END_RANGE(AWS_CRT_JAVA_PACKAGE_ID), }; diff --git a/src/native/mqtt5_client.c b/src/native/mqtt5_client.c index 6877675c8..df7ca7be1 100644 --- a/src/native/mqtt5_client.c +++ b/src/native/mqtt5_client.c @@ -64,7 +64,7 @@ struct aws_http_proxy_options_java_jni { ******************************************************************************/ static void s_aws_mqtt5_client_log_and_throw_exception(JNIEnv *env, const char *message, int error_code) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s - error code: %i", message, error_code); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s - error code: %i", message, error_code); // raise error to update the "last_error_code" aws_raise_error(error_code); aws_jni_throw_runtime_exception(env, "%s - error code: %i", message, error_code); @@ -83,7 +83,7 @@ static void s_aws_mqtt5_http_proxy_options_java_destroy( if (!http_options) { return; } - AWS_LOGF_DEBUG(AWS_LS_MQTT_CLIENT, "id=%p: Destroying JavaHttpProxyOptions", (void *)http_options); + AWS_LOGF_DEBUG(AWS_LS_MQTT5_CLIENT, "id=%p: Destroying JavaHttpProxyOptions", (void *)http_options); if (aws_byte_buf_is_valid(&http_options->proxy_host_buf)) { aws_byte_buf_clean_up(&http_options->proxy_host_buf); @@ -108,7 +108,7 @@ static struct aws_http_proxy_options_java_jni *s_aws_mqtt5_http_proxy_options_cr struct aws_http_proxy_options_java_jni *http_options = aws_mem_calloc(allocator, 1, sizeof(struct aws_http_proxy_options_java_jni)); AWS_LOGF_DEBUG( - AWS_LS_MQTT_CLIENT, "JavaHttpProxyOptions=%p: Created new JavaHttpProxyOptions", (void *)http_options); + AWS_LS_MQTT5_CLIENT, "JavaHttpProxyOptions=%p: Created new JavaHttpProxyOptions", (void *)http_options); jobject jni_proxy_connection_type = (*env)->CallObjectMethod( env, java_http_proxy_options, http_proxy_options_properties.proxy_get_connection_type_id); @@ -124,12 +124,12 @@ static struct aws_http_proxy_options_java_jni *s_aws_mqtt5_http_proxy_options_cr if (jni_proxy_connection_type_value) { int32_t jni_proxy_connection_type_value_check = (int32_t)jni_proxy_connection_type_value; if (jni_proxy_connection_type_value_check < 0) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "HTTP Proxy Options connection type is less than 0"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "HTTP Proxy Options connection type is less than 0"); goto on_error; } else if (jni_proxy_connection_type_value_check > AWS_HPCT_HTTP_TUNNEL) { /* The (current) maximum enum */ /* value */ AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "HTTP Proxy Options connection type is more than maximum allowed value"); + AWS_LS_MQTT5_CLIENT, "HTTP Proxy Options connection type is more than maximum allowed value"); goto on_error; } else { http_options->options.connection_type = @@ -250,7 +250,7 @@ static void aws_mqtt5_client_java_destroy( return; } - AWS_LOGF_DEBUG(AWS_LS_MQTT_CLIENT, "java_client=%p: Destroying MQTT5 client", (void *)java_client); + AWS_LOGF_DEBUG(AWS_LS_MQTT5_CLIENT, "java_client=%p: Destroying MQTT5 client", (void *)java_client); if (java_client->jni_client) { (*env)->DeleteGlobalRef(env, java_client->jni_client); @@ -297,7 +297,7 @@ static void s_aws_mqtt5_client_java_lifecycle_event(const struct aws_mqtt5_clien struct aws_mqtt5_client_java_jni *java_client = (struct aws_mqtt5_client_java_jni *)event->user_data; if (!java_client) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "LifecycleEvent: invalid client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "LifecycleEvent: invalid client"); return; } @@ -306,7 +306,7 @@ static void s_aws_mqtt5_client_java_lifecycle_event(const struct aws_mqtt5_clien JNIEnv *env = aws_jni_acquire_thread_env(jvm); if (env == NULL) { /* If we can't get an environment, then the JVM is probably shutting down. Don't crash. */ - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "LifecycleEvent: could not get env"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "LifecycleEvent: could not get env"); return; } @@ -365,7 +365,7 @@ static void s_aws_mqtt5_client_java_lifecycle_event(const struct aws_mqtt5_clien if (event->connack_data != NULL) { connack_data = s_aws_mqtt5_client_create_jni_connack_packet_from_native(env, event->connack_data); if (connack_data == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "LifecycleEvent: creating ConnAck packet failed!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "LifecycleEvent: creating ConnAck packet failed!"); goto clean_up; } } @@ -374,7 +374,7 @@ static void s_aws_mqtt5_client_java_lifecycle_event(const struct aws_mqtt5_clien if (event->disconnect_data != NULL) { disconnect_data = s_aws_mqtt5_client_create_jni_disconnect_packet_from_native(env, event->disconnect_data); if (disconnect_data == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "LifecycleEvent: creating Disconnect packet failed!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "LifecycleEvent: creating Disconnect packet failed!"); goto clean_up; } } @@ -492,7 +492,7 @@ static void s_aws_mqtt5_client_java_lifecycle_event(const struct aws_mqtt5_clien java_lifecycle_return_data); break; default: - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "LifecycleEvent: unsupported event type: %i", event->event_type); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "LifecycleEvent: unsupported event type: %i", event->event_type); } goto clean_up; @@ -512,12 +512,12 @@ static void s_aws_mqtt5_client_java_publish_received( struct aws_mqtt5_client_java_jni *java_client = (struct aws_mqtt5_client_java_jni *)user_data; if (!java_client) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "publishReceived function: invalid client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "publishReceived function: invalid client"); return; } if (!publish) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "publishReceived function: invalid publish packet"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "publishReceived function: invalid publish packet"); return; } @@ -526,7 +526,7 @@ static void s_aws_mqtt5_client_java_publish_received( JNIEnv *env = aws_jni_acquire_thread_env(jvm); if (env == NULL) { /* If we can't get an environment, then the JVM is probably shutting down. Don't crash. */ - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "publishReceived function: could not get env"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "publishReceived function: could not get env"); return; } @@ -627,13 +627,13 @@ static void s_aws_mqtt5_client_java_publish_completion( struct aws_mqtt5_client_publish_return_data *return_data = (struct aws_mqtt5_client_publish_return_data *)user_data; if (!return_data) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishCompletion function: invalid return data!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishCompletion function: invalid return data!"); return; } struct aws_mqtt5_client_java_jni *java_client = return_data->java_client; if (!java_client) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishCompletion function: invalid client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishCompletion function: invalid client"); goto clean_up; } @@ -642,7 +642,7 @@ static void s_aws_mqtt5_client_java_publish_completion( env = aws_jni_acquire_thread_env(jvm); if (env == NULL) { /* If we can't get an environment, then the JVM is probably shutting down. Don't crash. */ - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishCompletion function: could not get env"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishCompletion function: could not get env"); goto clean_up; } @@ -654,7 +654,7 @@ static void s_aws_mqtt5_client_java_publish_completion( /* If this result is supposed to have a packet and does not, then error right away */ if (packet_type != AWS_MQTT5_PT_NONE && packet == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishCompletion function: packet type but no packet!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishCompletion function: packet type but no packet!"); goto exception; } @@ -677,7 +677,7 @@ static void s_aws_mqtt5_client_java_publish_completion( jint local_frame_result = (*env)->PushLocalFrame(env, (jint)references_needed); if (local_frame_result != 0) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "PublishCompletion function: could not push local JNI frame with 12 allocation minimum"); exception_error_code = AWS_ERROR_INVALID_STATE; goto exception; @@ -713,7 +713,7 @@ static void s_aws_mqtt5_client_java_publish_completion( aws_jni_check_and_clear_exception(env); /* To hide JNI warning */ } else { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishCompletion function called with unknown packet type!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishCompletion function called with unknown packet type!"); exception_error_code = AWS_ERROR_INVALID_STATE; goto exception; } @@ -722,7 +722,7 @@ static void s_aws_mqtt5_client_java_publish_completion( (*env)->CallBooleanMethod( env, jni_publish_future, completable_future_properties.complete_method_id, publish_packet_result_data); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishCompletion function: exception when completing future"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishCompletion function: exception when completing future"); goto exception; } @@ -770,12 +770,12 @@ static void s_aws_mqtt5_client_java_subscribe_completion( struct aws_mqtt5_client_subscribe_return_data *return_data = (struct aws_mqtt5_client_subscribe_return_data *)user_data; if (!return_data) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribeCompletion: invalid return data!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribeCompletion: invalid return data!"); return; } struct aws_mqtt5_client_java_jni *java_client = return_data->java_client; if (!java_client) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribeCompletion: invalid client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribeCompletion: invalid client"); goto clean_up; } @@ -784,7 +784,7 @@ static void s_aws_mqtt5_client_java_subscribe_completion( env = aws_jni_acquire_thread_env(jvm); if (env == NULL) { /* If we can't get an environment, then the JVM is probably shutting down. Don't crash. */ - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribeCompletion: could not get env"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribeCompletion: could not get env"); goto clean_up; } @@ -818,7 +818,7 @@ static void s_aws_mqtt5_client_java_subscribe_completion( jint local_frame_result = (*env)->PushLocalFrame(env, (jint)references_needed); if (local_frame_result != 0) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "SubscribeCompletion: could not push local JNI frame with 4 allocation minimum"); + AWS_LS_MQTT5_CLIENT, "SubscribeCompletion: could not push local JNI frame with 4 allocation minimum"); exception_error_code = AWS_ERROR_INVALID_STATE; goto exception; } @@ -854,7 +854,7 @@ static void s_aws_mqtt5_client_java_subscribe_completion( mqtt5_suback_packet_properties.suback_native_add_suback_code_id, false) != AWS_OP_SUCCESS) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "Error when creating SubAckPacket from native: Could not set reason code"); exception_error_code = AWS_ERROR_INVALID_STATE; goto exception; @@ -869,7 +869,7 @@ static void s_aws_mqtt5_client_java_subscribe_completion( suback->user_properties, suback_packet_data, mqtt5_suback_packet_properties.suback_user_properties_field_id) == AWS_OP_ERR) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "When creating PubAckPacket from native could not add user property!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "When creating PubAckPacket from native could not add user property!"); exception_error_code = AWS_ERROR_INVALID_STATE; goto exception; } @@ -923,13 +923,13 @@ static void s_aws_mqtt5_client_java_unsubscribe_completion( struct aws_mqtt5_client_unsubscribe_return_data *return_data = (struct aws_mqtt5_client_unsubscribe_return_data *)user_data; if (!return_data) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "UnsubscribeCompletion: invalid return data!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "UnsubscribeCompletion: invalid return data!"); return; } struct aws_mqtt5_client_java_jni *java_client = return_data->java_client; if (!java_client) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "UnsubscribeCompletion: invalid client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "UnsubscribeCompletion: invalid client"); goto clean_up; } @@ -938,7 +938,7 @@ static void s_aws_mqtt5_client_java_unsubscribe_completion( env = aws_jni_acquire_thread_env(jvm); if (env == NULL) { /* If we can't get an environment, then the JVM is probably shutting down. Don't crash. */ - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "UnsubscribeCompletion: could not get env"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "UnsubscribeCompletion: could not get env"); goto clean_up; } @@ -967,7 +967,7 @@ static void s_aws_mqtt5_client_java_unsubscribe_completion( jint local_frame_result = (*env)->PushLocalFrame(env, (jint)references_needed); if (local_frame_result != 0) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "UnsubscribeCompletion: could not push local JNI frame with 4 allocation minimum"); + AWS_LS_MQTT5_CLIENT, "UnsubscribeCompletion: could not push local JNI frame with 4 allocation minimum"); exception_error_code = AWS_ERROR_INVALID_STATE; goto exception; } @@ -1004,7 +1004,7 @@ static void s_aws_mqtt5_client_java_unsubscribe_completion( mqtt5_unsuback_packet_properties.unsuback_native_add_unsuback_code_id, false) != AWS_OP_SUCCESS) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "Error when creating UnsubAckPacket from native: Could not set reason code"); exception_error_code = AWS_ERROR_INVALID_STATE; goto exception; @@ -1019,7 +1019,7 @@ static void s_aws_mqtt5_client_java_unsubscribe_completion( unsuback->user_properties, unsuback_packet_data, mqtt5_unsuback_packet_properties.unsuback_user_properties_field_id) == AWS_OP_ERR) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "When creating UnsubAckPacket from native could not add user property!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "When creating UnsubAckPacket from native could not add user property!"); exception_error_code = AWS_ERROR_INVALID_STATE; goto exception; } @@ -1050,7 +1050,7 @@ static void s_aws_mqtt5_client_java_termination(void *complete_ctx) { struct aws_mqtt5_client_java_jni *java_client = (struct aws_mqtt5_client_java_jni *)complete_ctx; if (!java_client) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "MQTT5 client termination function in JNI called, but with invalid java_client"); + AWS_LS_MQTT5_CLIENT, "MQTT5 client termination function in JNI called, but with invalid java_client"); return; } @@ -1059,7 +1059,7 @@ static void s_aws_mqtt5_client_java_termination(void *complete_ctx) { JNIEnv *env = aws_jni_acquire_thread_env(jvm); if (env == NULL) { /* If we can't get an environment, then the JVM is probably shutting down. Don't crash. */ - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "MQTT5 client termination function in JNI called, but could not get env"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "MQTT5 client termination function in JNI called, but could not get env"); return; } @@ -1180,12 +1180,12 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl if (!java_client->client) { error_code = AWS_ERROR_INVALID_ARGUMENT; - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.publish: Invalid/null native client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.publish: Invalid/null native client"); goto exception; } if (!jni_publish_packet) { error_code = AWS_ERROR_INVALID_ARGUMENT; - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.publish: Invalid/Null publish packet!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.publish: Invalid/Null publish packet!"); goto exception; } @@ -1202,7 +1202,7 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl java_publish_packet = aws_mqtt5_packet_publish_view_create_from_java(env, allocator, jni_publish_packet); if (!java_publish_packet) { error_code = aws_last_error(); - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.publish: Could not create native publish packet!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.publish: Could not create native publish packet!"); goto exception; } @@ -1211,7 +1211,7 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl if (return_result != AWS_OP_SUCCESS) { error_code = aws_last_error(); AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "Mqtt5Client.publish: Could not publish packet! Error code: %i", return_result); + AWS_LS_MQTT5_CLIENT, "Mqtt5Client.publish: Could not publish packet! Error code: %i", return_result); goto exception; } goto clean_up; @@ -1263,12 +1263,12 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl if (!java_client->client) { error_code = AWS_ERROR_INVALID_ARGUMENT; - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.subscribe: Invalid/null native client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.subscribe: Invalid/null native client"); goto exception; } if (!jni_subscribe_packet) { error_code = AWS_ERROR_INVALID_ARGUMENT; - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.subscribe: Invalid/Null subscribe packet!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.subscribe: Invalid/Null subscribe packet!"); goto exception; } @@ -1285,7 +1285,7 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl java_subscribe_packet = aws_mqtt5_packet_subscribe_view_create_from_java(env, allocator, jni_subscribe_packet); if (java_subscribe_packet == NULL) { error_code = aws_last_error(); - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.subscribe: Could not create native subscribe packet!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.subscribe: Could not create native subscribe packet!"); goto exception; } @@ -1293,7 +1293,7 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl java_client->client, aws_mqtt5_packet_subscribe_view_get_packet(java_subscribe_packet), &completion_options); if (return_result != AWS_OP_SUCCESS) { error_code = aws_last_error(); - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.subscribe: Subscribe failed! Error code: %i", return_result); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.subscribe: Subscribe failed! Error code: %i", return_result); goto exception; } goto clean_up; @@ -1345,12 +1345,12 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl if (!java_client->client) { error_code = AWS_ERROR_INVALID_ARGUMENT; - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.unsubscribe: Invalid/null native client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.unsubscribe: Invalid/null native client"); goto exception; } if (!jni_unsubscribe_packet) { error_code = AWS_ERROR_INVALID_ARGUMENT; - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.unsubscribe: Invalid/Null unsubscribe packet!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.unsubscribe: Invalid/Null unsubscribe packet!"); goto exception; } @@ -1368,7 +1368,7 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl aws_mqtt5_packet_unsubscribe_view_create_from_java(env, allocator, jni_unsubscribe_packet); if (!java_unsubscribe_packet) { error_code = aws_last_error(); - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Mqtt5Client.unsubscribe: Could not create native unsubscribe packet!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Mqtt5Client.unsubscribe: Could not create native unsubscribe packet!"); goto exception; } @@ -1379,7 +1379,7 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl if (return_result != AWS_OP_SUCCESS) { error_code = aws_last_error(); AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "Mqtt5Client.unsubscribe: Unsubscribe failed! Error code: %i", return_result); + AWS_LS_MQTT5_CLIENT, "Mqtt5Client.unsubscribe: Unsubscribe failed! Error code: %i", return_result); goto exception; } goto clean_up; @@ -1511,11 +1511,11 @@ static void s_aws_mqtt5_client_java_websocket_handshake_transform( struct aws_mqtt5_client_java_jni *java_client = (struct aws_mqtt5_client_java_jni *)user_data; if (!java_client) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Websocket handshake function in JNI called without valid client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Websocket handshake function in JNI called without valid client"); return; } if (!java_client->jni_client || !java_client->client) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Websocket handshake function in JNI called with already freed client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Websocket handshake function in JNI called with already freed client"); return; } @@ -1540,7 +1540,7 @@ static void s_aws_mqtt5_client_java_websocket_handshake_transform( jobject java_http_request = aws_java_http_request_from_native(env, request, NULL); if (!java_http_request) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not create a HttpRequest for Java in MQTT5 client"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not create a HttpRequest for Java in MQTT5 client"); aws_raise_error(AWS_ERROR_UNKNOWN); goto error; } @@ -1581,7 +1581,7 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5Cl int error_code = AWS_ERROR_SUCCESS; if (!ws_handshake) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Websocket handshake complete function in JNI called without handshake"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Websocket handshake complete function in JNI called without handshake"); return; } @@ -1617,7 +1617,7 @@ static int s_initialize_topic_aliasing_options( jint enum_value = (*env)->CallIntMethod( env, jni_outbound_behavior, mqtt5_outbound_topic_alias_behavior_type_properties.get_value_method_id); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Error getting native value from OutboundTopicAliasBehaviorType"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Error getting native value from OutboundTopicAliasBehaviorType"); return aws_raise_error(AWS_ERROR_INVALID_STATE); } @@ -1632,7 +1632,7 @@ static int s_initialize_topic_aliasing_options( (*env)->CallIntMethod(env, jni_outbound_cache_max_size, boxed_integer_properties.integer_get_value_id); if (int_value < 0 || int_value > UINT16_MAX) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Invalid outbound cache size value: %d", int_value); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Invalid outbound cache size value: %d", int_value); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } @@ -1645,7 +1645,7 @@ static int s_initialize_topic_aliasing_options( jint enum_value = (*env)->CallIntMethod( env, jni_inbound_behavior, mqtt5_inbound_topic_alias_behavior_type_properties.get_value_method_id); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Error getting native value from InboundTopicAliasBehaviorType"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Error getting native value from InboundTopicAliasBehaviorType"); return aws_raise_error(AWS_ERROR_INVALID_STATE); } @@ -1660,7 +1660,7 @@ static int s_initialize_topic_aliasing_options( (*env)->CallIntMethod(env, jni_inbound_cache_max_size, boxed_integer_properties.integer_get_value_id); if (int_value < 0 || int_value > UINT16_MAX) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Invalid inbound cache size value: %d", int_value); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Invalid inbound cache size value: %d", int_value); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } @@ -1715,7 +1715,7 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_mqtt5_Mqtt5Client_mqtt5C struct aws_mqtt5_client_java_jni *java_client = aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_client_java_jni)); - AWS_LOGF_DEBUG(AWS_LS_MQTT_CLIENT, "java_client=%p: Initializing MQTT5 client", (void *)java_client); + AWS_LOGF_DEBUG(AWS_LS_MQTT5_CLIENT, "java_client=%p: Initializing MQTT5 client", (void *)java_client); if (java_client == NULL) { s_aws_mqtt5_client_log_and_throw_exception( env, "MQTT5 client new: could not initialize new client", AWS_ERROR_INVALID_STATE); diff --git a/src/native/mqtt5_packets.c b/src/native/mqtt5_packets.c index d7d3fea2e..ee00262db 100644 --- a/src/native/mqtt5_packets.c +++ b/src/native/mqtt5_packets.c @@ -139,7 +139,7 @@ static int s_populate_user_properties( (*env)->CallObjectMethod(env, jni_user_properties_list, boxed_list_properties.list_get_id, (jint)i); if (!jni_property || aws_jni_check_and_clear_exception(env)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "Could not populate user properties due to being unable to get property in list from Java"); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } @@ -148,7 +148,7 @@ static int s_populate_user_properties( (jstring)(*env)->GetObjectField(env, jni_property, mqtt5_user_property_properties.property_key_id); if (aws_jni_check_and_clear_exception(env) || !jni_property_key) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "Could not populate user properties due to exception when getting property key"); return aws_raise_error(AWS_ERROR_INVALID_STATE); } @@ -156,17 +156,17 @@ static int s_populate_user_properties( (jstring)(*env)->GetObjectField(env, jni_property, mqtt5_user_property_properties.property_value_id); if (aws_jni_check_and_clear_exception(env) || !jni_property_value) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "Could not populate user properties due to exception when getting property value"); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (!jni_property_key) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Error reading a user property: Key in user property was NULL!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Error reading a user property: Key in user property was NULL!"); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (!jni_property_value) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Error reading a user property: Key in user property was NULL!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Error reading a user property: Key in user property was NULL!"); return aws_raise_error(AWS_ERROR_INVALID_STATE); } @@ -266,22 +266,22 @@ int aws_get_uint16_from_jobject( jobject jlong_obj = (*env)->GetObjectField(env, object, object_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (jlong_obj) { jlong jlong_value = (*env)->CallLongMethod(env, jlong_obj, boxed_long_properties.long_value_method_id); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } int64_t jlong_value_check = (int64_t)jlong_value; if (jlong_value_check < 0) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: %s is less than 0", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: %s is less than 0", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } else if (jlong_value_check > UINT16_MAX) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "%s create_from_java: %s is more than UINT16_MAX", object_name, field_name); + AWS_LS_MQTT5_CLIENT, "%s create_from_java: %s is more than UINT16_MAX", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } *result = (uint16_t)jlong_value; @@ -318,22 +318,22 @@ int aws_get_uint32_from_jobject( jobject jlong_obj = (*env)->GetObjectField(env, object, object_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (jlong_obj) { jlong jlong_value = (*env)->CallLongMethod(env, jlong_obj, boxed_long_properties.long_value_method_id); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } int64_t jlong_value_check = (int64_t)jlong_value; if (jlong_value_check < 0) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: %s is less than 0", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: %s is less than 0", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } else if (jlong_value_check > UINT32_MAX) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "%s create_from_java: %s is more than UINT32_MAX", object_name, field_name); + AWS_LS_MQTT5_CLIENT, "%s create_from_java: %s is more than UINT32_MAX", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } *result = (uint32_t)jlong_value_check; @@ -370,18 +370,18 @@ int aws_get_uint64_from_jobject( jobject jlong_obj = (*env)->GetObjectField(env, object, object_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (jlong_obj) { jlong jlong_value = (*env)->CallLongMethod(env, jlong_obj, boxed_long_properties.long_value_method_id); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } int64_t jlong_value_check = (int64_t)jlong_value; if (jlong_value_check < 0) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: %s is less than 0", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: %s is less than 0", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } *result = (uint64_t)jlong_value_check; @@ -419,7 +419,7 @@ int aws_get_string_from_jobject( jstring jstring_value = (jstring)(*env)->GetObjectField(env, object, object_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (jstring_value) { @@ -461,7 +461,7 @@ int aws_get_byte_array_from_jobject( jbyteArray jbyte_array_value = (jbyteArray)(*env)->GetObjectField(env, object, object_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (jbyte_array_value) { @@ -502,7 +502,7 @@ int aws_get_boolean_from_jobject( jobject jboolean_obj = (*env)->GetObjectField(env, object, object_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (jboolean_obj) { @@ -510,7 +510,10 @@ int aws_get_boolean_from_jobject( (*env)->CallBooleanMethod(env, jboolean_obj, boxed_boolean_properties.boolean_get_value_id); if (aws_jni_check_and_clear_exception(env)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting native value from %s", object_name, field_name); + AWS_LS_MQTT5_CLIENT, + "%s create_from_java: Error getting native value from %s", + object_name, + field_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } *result_boolean_int = (uint8_t)jboolean_value; @@ -546,7 +549,7 @@ int aws_get_enum_from_jobject( if (enum_value_destination == NULL) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s due to null destination", object_name, enum_name); @@ -555,23 +558,26 @@ int aws_get_enum_from_jobject( jobject jni_retain_handling_type = (*env)->CallObjectMethod(env, object, object_enum_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting %s", object_name, enum_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting %s", object_name, enum_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (jni_retain_handling_type) { jint enum_value = (*env)->CallIntMethod(env, jni_retain_handling_type, enum_value_field); if (aws_jni_check_and_clear_exception(env)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting native value from %s", object_name, enum_name); + AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting native value from %s", object_name, enum_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (enum_value < 0) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "%s create_from_java: Native value from %s is less than 0", object_name, enum_name); + AWS_LS_MQTT5_CLIENT, + "%s create_from_java: Native value from %s is less than 0", + object_name, + enum_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } else if ((int32_t)enum_value > UINT16_MAX) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "%s create_from_java: Native value from %s is more than UINT16_MAX", object_name, enum_name); @@ -608,14 +614,14 @@ static int s_get_user_properties_from_packet_optional( jobject jni_list = (*env)->GetObjectField(env, packet, packet_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting user properties list", packet_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting user properties list", packet_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } if (jni_list) { jint jni_user_properties_size = (*env)->CallIntMethod(env, jni_list, boxed_list_properties.list_size_id); if (aws_jni_check_and_clear_exception(env)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting user properties list size", packet_name); + AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting user properties list size", packet_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } *packet_user_property_count = (size_t)jni_user_properties_size; @@ -625,7 +631,7 @@ static int s_get_user_properties_from_packet_optional( jni_user_properties_struct_holder, *packet_user_property_count)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "%s create_from_java: Could not create user properties array", packet_name); + AWS_LS_MQTT5_CLIENT, "%s create_from_java: Could not create user properties array", packet_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } int populate_result = s_populate_user_properties( @@ -657,13 +663,14 @@ static int s_get_qos_from_packet( jobject jni_qos = (*env)->CallObjectMethod(env, packet, packet_field); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting QoS", packet_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting QoS", packet_name); return AWS_OP_ERR; } if (jni_qos) { jint jni_qos_value = (*env)->CallIntMethod(env, jni_qos, mqtt5_packet_qos_properties.qos_get_value_id); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: Error getting native value from QoS", packet_name); + AWS_LOGF_ERROR( + AWS_LS_MQTT5_CLIENT, "%s create_from_java: Error getting native value from QoS", packet_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } *packet_qos = (enum aws_mqtt5_qos)jni_qos_value; @@ -675,7 +682,7 @@ static int s_get_qos_from_packet( } } else { if (!optional) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "%s create_from_java: QoS not found", packet_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "%s create_from_java: QoS not found", packet_name); return aws_raise_error(AWS_ERROR_INVALID_STATE); } } @@ -703,7 +710,7 @@ void aws_mqtt5_packet_connect_view_java_destroy( if (!java_packet) { return; } - AWS_LOGF_DEBUG(AWS_LS_MQTT_CLIENT, "id=%p: Destroying ConnectPacket", (void *)java_packet); + AWS_LOGF_DEBUG(AWS_LS_MQTT5_CLIENT, "id=%p: Destroying ConnectPacket", (void *)java_packet); if (aws_byte_buf_is_valid(&java_packet->client_id_buf)) { aws_byte_buf_clean_up(&java_packet->client_id_buf); @@ -734,7 +741,7 @@ struct aws_mqtt5_packet_connect_view_java_jni *aws_mqtt5_packet_connect_view_cre struct aws_mqtt5_packet_connect_view_java_jni *java_packet = aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_packet_connect_view_java_jni)); if (java_packet == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "ConnectPacket create_from_java: Creating new ConnectPacket failed"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "ConnectPacket create_from_java: Creating new ConnectPacket failed"); return NULL; } @@ -897,14 +904,14 @@ struct aws_mqtt5_packet_connect_view_java_jni *aws_mqtt5_packet_connect_view_cre jobject jni_will_packet = (*env)->GetObjectField(env, java_connect_packet, mqtt5_connect_packet_properties.connect_will_field_id); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "ConnectPacket create_from_java: Error getting will packet"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "ConnectPacket create_from_java: Error getting will packet"); goto on_error; } if (jni_will_packet) { java_packet->will_publish_packet = aws_mqtt5_packet_publish_view_create_from_java(env, allocator, jni_will_packet); if (java_packet->will_publish_packet == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "ConnectPacket create_from_java: Error getting will packet"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "ConnectPacket create_from_java: Error getting will packet"); goto on_error; } java_packet->packet.will = &java_packet->will_publish_packet->packet; @@ -951,7 +958,7 @@ void aws_mqtt5_packet_disconnect_view_java_destroy( if (!java_packet) { return; } - AWS_LOGF_DEBUG(AWS_LS_MQTT_CLIENT, "id=%p: Destroying DisconnectPacket", (void *)java_packet); + AWS_LOGF_DEBUG(AWS_LS_MQTT5_CLIENT, "id=%p: Destroying DisconnectPacket", (void *)java_packet); if (aws_byte_buf_is_valid(&java_packet->reason_string_buf)) { aws_byte_buf_clean_up(&java_packet->reason_string_buf); @@ -973,7 +980,7 @@ struct aws_mqtt5_packet_disconnect_view_java_jni *aws_mqtt5_packet_disconnect_vi struct aws_mqtt5_packet_disconnect_view_java_jni *java_packet = aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_packet_disconnect_view_java_jni)); if (java_packet == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "DisconnectPacket create_from_java: Creating new DisconnectPacket failed"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "DisconnectPacket create_from_java: Creating new DisconnectPacket failed"); return NULL; } @@ -1085,7 +1092,7 @@ void aws_mqtt5_packet_publish_view_java_destroy( if (!java_packet) { return; } - AWS_LOGF_DEBUG(AWS_LS_MQTT_CLIENT, "id=%p: Destroying PublishPacket", (void *)java_packet); + AWS_LOGF_DEBUG(AWS_LS_MQTT5_CLIENT, "id=%p: Destroying PublishPacket", (void *)java_packet); if (aws_byte_buf_is_valid(&java_packet->payload_buf)) { aws_byte_buf_clean_up(&java_packet->payload_buf); @@ -1116,7 +1123,7 @@ struct aws_mqtt5_packet_publish_view_java_jni *aws_mqtt5_packet_publish_view_cre struct aws_mqtt5_packet_publish_view_java_jni *java_packet = aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_packet_publish_view_java_jni)); if (java_packet == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishPacket create_from_java: Creating new PublishPacket failed"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishPacket create_from_java: Creating new PublishPacket failed"); return NULL; } @@ -1147,7 +1154,7 @@ struct aws_mqtt5_packet_publish_view_java_jni *aws_mqtt5_packet_publish_view_cre &java_packet->packet.qos, false, NULL) == AWS_OP_ERR) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishPacket create_from_java: QOS not found"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishPacket create_from_java: QOS not found"); goto on_error; } @@ -1177,7 +1184,7 @@ struct aws_mqtt5_packet_publish_view_java_jni *aws_mqtt5_packet_publish_view_cre &java_packet->topic_cursor, false, NULL) == AWS_OP_ERR) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "PublishPacket create_from_java: No topic found"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "PublishPacket create_from_java: No topic found"); goto on_error; } java_packet->packet.topic = java_packet->topic_cursor; @@ -1319,7 +1326,7 @@ void aws_mqtt5_packet_subscribe_view_java_destroy( if (!java_packet) { return; } - AWS_LOGF_DEBUG(AWS_LS_MQTT_CLIENT, "id=%p: Destroying SubscribePacket", (void *)java_packet); + AWS_LOGF_DEBUG(AWS_LS_MQTT5_CLIENT, "id=%p: Destroying SubscribePacket", (void *)java_packet); s_cleanup_two_aws_array( env, &java_packet->jni_user_properties_holder, &java_packet->jni_user_properties_struct_holder); @@ -1339,7 +1346,7 @@ struct aws_mqtt5_packet_subscribe_view_java_jni *aws_mqtt5_packet_subscribe_view } if (!jni_subscriptions) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: Creating new SubscribePacket failed due to no subscriptions!"); return NULL; } @@ -1350,20 +1357,20 @@ struct aws_mqtt5_packet_subscribe_view_java_jni *aws_mqtt5_packet_subscribe_view size_t subscriptions_filter_size = (size_t)jni_subscriptions_size; if (subscriptions_filter_size <= 0) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribePacket create_from_java: subscriptions count is 0"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: subscriptions count is 0"); return NULL; } struct aws_mqtt5_packet_subscribe_view_java_jni *java_packet = aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_packet_subscribe_view_java_jni)); if (java_packet == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribePacket create_from_java: Creating new SubscribePacket failed"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: Creating new SubscribePacket failed"); return NULL; } int array_init = aws_array_list_init_dynamic( &java_packet->topic_filters, allocator, subscriptions_filter_size, sizeof(struct aws_mqtt5_subscription_view)); if (array_init != AWS_OP_SUCCESS) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribePacket create_from_java: Creating new SubscribePacket failed"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: Creating new SubscribePacket failed"); goto on_error; } int jni_array_init = aws_array_list_init_dynamic( @@ -1372,7 +1379,7 @@ struct aws_mqtt5_packet_subscribe_view_java_jni *aws_mqtt5_packet_subscribe_view subscriptions_filter_size, sizeof(struct buffer_and_cursor_array_holder_struct)); if (jni_array_init != AWS_OP_SUCCESS) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribePacket create_from_java: Creating new SubscribePacket failed"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: Creating new SubscribePacket failed"); goto on_error; } @@ -1403,7 +1410,7 @@ struct aws_mqtt5_packet_subscribe_view_java_jni *aws_mqtt5_packet_subscribe_view jobject jni_packet_subscribe_subscription = (*env)->CallObjectMethod(env, jni_subscriptions, boxed_list_properties.list_get_id, (jint)i); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribePacket create_from_java: Error getting topic filters"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: Error getting topic filters"); goto on_error; } @@ -1411,7 +1418,7 @@ struct aws_mqtt5_packet_subscribe_view_java_jni *aws_mqtt5_packet_subscribe_view env, jni_packet_subscribe_subscription, mqtt5_subscription_properties.subscribe_get_topic_filter_id); if (aws_jni_check_and_clear_exception(env)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "SubscribePacket create_from_java: Error getting subscription topic filter"); + AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: Error getting subscription topic filter"); goto on_error; } if (jni_topic_filter) { @@ -1425,7 +1432,7 @@ struct aws_mqtt5_packet_subscribe_view_java_jni *aws_mqtt5_packet_subscribe_view jni_topic_filter = NULL; } else { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "SubscribePacket create_from_java: subscription topic filter is required"); + AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: subscription topic filter is required"); goto on_error; } @@ -1437,7 +1444,7 @@ struct aws_mqtt5_packet_subscribe_view_java_jni *aws_mqtt5_packet_subscribe_view &subscription_view.qos, false, NULL) == AWS_OP_ERR) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "SubscribePacket create_from_java: subscription QoS is required"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "SubscribePacket create_from_java: subscription QoS is required"); goto on_error; } @@ -1536,7 +1543,7 @@ void aws_mqtt5_packet_unsubscribe_view_java_destroy( if (!java_packet) { return; } - AWS_LOGF_DEBUG(AWS_LS_MQTT_CLIENT, "id=%p: Destroying UnsubscribePacket", (void *)java_packet); + AWS_LOGF_DEBUG(AWS_LS_MQTT5_CLIENT, "id=%p: Destroying UnsubscribePacket", (void *)java_packet); s_cleanup_two_aws_array( env, &java_packet->jni_user_properties_holder, &java_packet->jni_user_properties_struct_holder); @@ -1556,7 +1563,7 @@ struct aws_mqtt5_packet_unsubscribe_view_java_jni *aws_mqtt5_packet_unsubscribe_ } if (!jni_topic_filters) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "UnsubscribePacket create_from_java: Creating new UnsubscribePacket failed due to no topic filters"); return NULL; } @@ -1565,13 +1572,13 @@ struct aws_mqtt5_packet_unsubscribe_view_java_jni *aws_mqtt5_packet_unsubscribe_ jint jni_topic_filter_size = (*env)->CallIntMethod(env, jni_topic_filters, boxed_list_properties.list_size_id); if (aws_jni_check_and_clear_exception(env)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "UnsubscribePacket create_from_java: Created new UnsubscribePacket failed due to no topic filters"); return NULL; } int32_t jni_topic_filter_size_check = (int32_t)jni_topic_filter_size; if (jni_topic_filter_size_check < 0) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "UnsubscribePacket create_from_java: No topic filters found"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "UnsubscribePacket create_from_java: No topic filters found"); return NULL; } else { topic_filter_size = (size_t)jni_topic_filter_size; @@ -1580,13 +1587,15 @@ struct aws_mqtt5_packet_unsubscribe_view_java_jni *aws_mqtt5_packet_unsubscribe_ struct aws_mqtt5_packet_unsubscribe_view_java_jni *java_packet = aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_packet_unsubscribe_view_java_jni)); if (java_packet == NULL) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "UnsubscribePacket create_from_java: Creating new UnsubscribePacket failed"); + AWS_LOGF_ERROR( + AWS_LS_MQTT5_CLIENT, "UnsubscribePacket create_from_java: Creating new UnsubscribePacket failed"); return NULL; } int array_init = aws_array_list_init_dynamic( &java_packet->topic_filters, allocator, topic_filter_size, sizeof(struct aws_byte_cursor)); if (array_init != AWS_OP_SUCCESS) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "UnsubscribePacket create_from_java: Creating new UnsubscribePacket failed"); + AWS_LOGF_ERROR( + AWS_LS_MQTT5_CLIENT, "UnsubscribePacket create_from_java: Creating new UnsubscribePacket failed"); goto on_error; } int jni_array_init = aws_array_list_init_dynamic( @@ -1595,7 +1604,8 @@ struct aws_mqtt5_packet_unsubscribe_view_java_jni *aws_mqtt5_packet_unsubscribe_ topic_filter_size, sizeof(struct buffer_and_cursor_array_holder_struct)); if (jni_array_init != AWS_OP_SUCCESS) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "UnsubscribePacket create_from_java: Creating new UnsubscribePacket failed"); + AWS_LOGF_ERROR( + AWS_LS_MQTT5_CLIENT, "UnsubscribePacket create_from_java: Creating new UnsubscribePacket failed"); goto on_error; } @@ -1609,7 +1619,7 @@ struct aws_mqtt5_packet_unsubscribe_view_java_jni *aws_mqtt5_packet_unsubscribe_ (jstring)(*env)->CallObjectMethod(env, jni_topic_filters, boxed_list_properties.list_get_id, (jint)i); if (aws_jni_check_and_clear_exception(env)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "UnsubscribePacket create_from_java: Error getting subscription topic filter"); + AWS_LS_MQTT5_CLIENT, "UnsubscribePacket create_from_java: Error getting subscription topic filter"); goto on_error; } if (jni_topic_filter) { diff --git a/src/native/mqtt5_utils.c b/src/native/mqtt5_utils.c index 2aa46e928..ffafbe31f 100644 --- a/src/native/mqtt5_utils.c +++ b/src/native/mqtt5_utils.c @@ -34,12 +34,12 @@ int s_set_jni_uint32_t_field_in_packet( jobject jni_long = (*env)->NewObject( env, boxed_long_properties.long_class, boxed_long_properties.constructor, (jlong)*native_integer); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not create uint32 field %s", field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not create uint32 field %s", field_name); return AWS_OP_ERR; } (*env)->SetObjectField(env, packet, field_id, jni_long); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not set uint32 field %s", field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not set uint32 field %s", field_name); return AWS_OP_ERR; } if (!optional) { @@ -67,12 +67,12 @@ int s_set_jni_uint16_t_field_in_packet( boxed_integer_properties.integer_constructor_id, (jint)*native_integer); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not create uint16 field %s", field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not create uint16 field %s", field_name); return AWS_OP_ERR; } (*env)->SetObjectField(env, packet, field_id, jni_int); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not set uint16 field %s", field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not set uint16 field %s", field_name); return AWS_OP_ERR; } if (!optional) { @@ -100,13 +100,13 @@ int s_set_jni_bool_field_in_packet( boxed_boolean_properties.boolean_constructor_id, (jboolean)*native_boolean); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not create boolean field %s", field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not create boolean field %s", field_name); return AWS_OP_ERR; } (*env)->SetObjectField(env, packet, field_id, jni_boolean); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not set boolean field %s", field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not set boolean field %s", field_name); return AWS_OP_ERR; } @@ -132,7 +132,7 @@ int s_set_jni_string_field_in_packet( jstring jni_string = aws_jni_string_from_cursor(env, native_cursor); (*env)->SetObjectField(env, packet, field_id, jni_string); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not set string field %s", field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not set string field %s", field_name); return AWS_OP_ERR; } if (!optional) { @@ -157,7 +157,7 @@ int s_set_jni_byte_array_field_in_packet( jbyteArray jni_byte = aws_jni_byte_array_from_cursor(env, native_cursor); (*env)->SetObjectField(env, packet, field_id, jni_byte); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not set string field %s", field_name); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not set string field %s", field_name); return AWS_OP_ERR; } if (!optional) { @@ -186,13 +186,13 @@ int s_set_user_properties_field( jobject jni_user_properties_list = (*env)->NewObject( env, boxed_array_list_properties.list_class, boxed_array_list_properties.list_constructor_id); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not make new user properties list"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not make new user properties list"); return AWS_OP_ERR; } (*env)->SetObjectField(env, packet, user_property_field_id, jni_user_properties_list); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not set new user properties list"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not set new user properties list"); return AWS_OP_ERR; } @@ -208,14 +208,14 @@ int s_set_user_properties_field( jni_new_property_name, jni_new_property_value); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not make new user property"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not make new user property"); return AWS_OP_ERR; } jboolean jni_add_result = (*env)->CallBooleanMethod( env, jni_user_properties_list, boxed_list_properties.list_add_id, jni_new_property); if (aws_jni_check_and_clear_exception(env)) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Could not add new user property"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Could not add new user property"); return AWS_OP_ERR; } @@ -272,7 +272,7 @@ jobject s_aws_mqtt5_client_create_jni_connack_packet_from_native( int reason_code_int = (int)native_connack_data->reason_code; if (reason_code_int < 0) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Error when creating ConnAckPacket from native: Reason code is negative!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Error when creating ConnAckPacket from native: Reason code is negative!"); return NULL; } (*env)->CallVoidMethod( @@ -307,7 +307,7 @@ jobject s_aws_mqtt5_client_create_jni_connack_packet_from_native( mqtt5_connack_packet_properties.connack_native_add_maximum_qos_id, true) != AWS_OP_SUCCESS) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "Error when creating ConnAckPacket from native: Could not set maximum QOS"); + AWS_LS_MQTT5_CLIENT, "Error when creating ConnAckPacket from native: Could not set maximum QOS"); return NULL; } } @@ -419,7 +419,7 @@ jobject s_aws_mqtt5_client_create_jni_connack_packet_from_native( connack_data, mqtt5_connack_packet_properties.connack_user_properties_field_id) != AWS_OP_SUCCESS) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "Error when creating ConnAckPacket from native: could not add user property!"); + AWS_LS_MQTT5_CLIENT, "Error when creating ConnAckPacket from native: could not add user property!"); return NULL; } @@ -443,7 +443,7 @@ jobject s_aws_mqtt5_client_create_jni_disconnect_packet_from_native( mqtt5_disconnect_packet_properties.disconnect_native_add_disconnect_reason_code_id, false) != AWS_OP_SUCCESS) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "Error when creating DisconnectPacket from native: Could not set reason code"); + AWS_LS_MQTT5_CLIENT, "Error when creating DisconnectPacket from native: Could not set reason code"); return NULL; } @@ -482,7 +482,7 @@ jobject s_aws_mqtt5_client_create_jni_disconnect_packet_from_native( disconnect_packet_data, mqtt5_disconnect_packet_properties.disconnect_user_properties_field_id) != AWS_OP_SUCCESS) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "Error when creating DisconnectPacket from native: could not add user property!"); + AWS_LS_MQTT5_CLIENT, "Error when creating DisconnectPacket from native: could not add user property!"); return NULL; } @@ -592,7 +592,7 @@ jobject s_aws_mqtt5_client_create_jni_publish_packet_from_native( publish_packet_data, mqtt5_publish_packet_properties.publish_native_set_qos_id, false) != AWS_OP_SUCCESS) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Error when creating PublishPacket from native: Could not set QOS"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Error when creating PublishPacket from native: Could not set QOS"); return NULL; } @@ -603,7 +603,7 @@ jobject s_aws_mqtt5_client_create_jni_publish_packet_from_native( mqtt5_publish_packet_properties.publish_retain_field_id, "retain", false) != AWS_OP_SUCCESS) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Error when creating PublishPacket from native: Could not set retain"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Error when creating PublishPacket from native: Could not set retain"); return NULL; } @@ -618,7 +618,7 @@ jobject s_aws_mqtt5_client_create_jni_publish_packet_from_native( mqtt5_publish_packet_properties.publish_native_set_payload_format_indicator_id, true) != AWS_OP_SUCCESS) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, "Error when creating PublishPacket from native: Could not set payload format"); + AWS_LS_MQTT5_CLIENT, "Error when creating PublishPacket from native: Could not set payload format"); return NULL; } } @@ -690,13 +690,13 @@ jobject s_aws_mqtt5_client_create_jni_publish_packet_from_native( env, jni_subscription_identifiers, boxed_list_properties.list_add_id, jni_identifier_obj); if (aws_jni_check_and_clear_exception(env)) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "When creating PublishPacket from native could not add subscription identifier!"); return NULL; } if ((bool)jni_add_result == false) { AWS_LOGF_ERROR( - AWS_LS_MQTT_CLIENT, + AWS_LS_MQTT5_CLIENT, "When creating PublishPacket from native could not add subscription identifier!"); return NULL; } @@ -709,7 +709,7 @@ jobject s_aws_mqtt5_client_create_jni_publish_packet_from_native( publish->user_properties, publish_packet_data, mqtt5_publish_packet_properties.publish_user_properties_field_id) == AWS_OP_ERR) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "When creating PublishPacket from native could not add user properties!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "When creating PublishPacket from native could not add user properties!"); return NULL; } @@ -730,7 +730,7 @@ jobject s_aws_mqtt5_client_create_jni_puback_packet_from_native( puback_packet_data, mqtt5_puback_packet_properties.puback_native_add_reason_code_id, false) != AWS_OP_SUCCESS) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "Error when creating PubAck result from native: Could not set reason code"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "Error when creating PubAck result from native: Could not set reason code"); return NULL; } if (s_set_jni_string_field_in_packet( @@ -748,7 +748,7 @@ jobject s_aws_mqtt5_client_create_jni_puback_packet_from_native( puback_packet->user_properties, puback_packet_data, mqtt5_puback_packet_properties.puback_user_properties_field_id) == AWS_OP_ERR) { - AWS_LOGF_ERROR(AWS_LS_MQTT_CLIENT, "When creating PubAckPacket from native could not add user property!"); + AWS_LOGF_ERROR(AWS_LS_MQTT5_CLIENT, "When creating PubAckPacket from native could not add user property!"); return NULL; } return puback_packet_data;