From 28d6357bb97d7653c838fb2ae60d8a4072aa1b7f Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Wed, 12 Oct 2022 20:35:06 +0900 Subject: [PATCH] change message size type from size_t to int - For compatibility between heterogeneous devices --- common/AittDiscovery.cc | 4 +- common/AittDiscovery.h | 6 +-- common/AittTransport.h | 12 ++---- include/AITT.h | 12 +++--- include/MQ.h | 13 +++--- include/aitt_c.h | 13 +++--- modules/tcp/AESEncryptor.cc | 6 +-- modules/tcp/AESEncryptor.h | 6 +-- modules/tcp/Module.cc | 18 +++------ modules/tcp/Module.h | 9 +---- modules/tcp/TCP.cc | 72 +++++++++++++++++----------------- modules/tcp/TCP.h | 20 +++++----- modules/tcp/samples/tcp_test.cc | 10 +++-- modules/tcp/tests/AESEncryptor_test.cc | 5 +-- modules/tcp/tests/TCP_test.cc | 4 +- modules/webrtc/Module.cc | 2 +- packaging/aitt.spec | 2 +- src/AITT.cc | 20 +++++----- src/AITTImpl.cc | 23 ++++++----- src/AITTImpl.h | 13 +++--- src/MosquittoMQ.cc | 8 ++-- src/MosquittoMQ.h | 8 ++-- src/NullTransport.cc | 10 +---- src/NullTransport.h | 8 +--- src/aitt_c.cc | 14 +++---- tests/AITT_TCP_test.cc | 9 ++--- tests/AITT_manualtest.cc | 4 +- tests/AITT_test.cc | 43 ++++++++++---------- tests/MosquittoMQ_test.cc | 10 ++--- tests/RequestResponse_test.cc | 28 ++++++------- tests/aitt_c_manualtest.cc | 2 +- tests/aitt_c_test.cc | 21 +++++----- 32 files changed, 201 insertions(+), 234 deletions(-) diff --git a/common/AittDiscovery.cc b/common/AittDiscovery.cc index 0b65af9..283a010 100644 --- a/common/AittDiscovery.cc +++ b/common/AittDiscovery.cc @@ -62,7 +62,7 @@ void AittDiscovery::Stop() discovery_mq->Disconnect(); } -void AittDiscovery::UpdateDiscoveryMsg(const std::string &protocol, const void *msg, size_t length) +void AittDiscovery::UpdateDiscoveryMsg(const std::string &protocol, const void *msg, int length) { auto it = discovery_map.find(protocol); if (it == discovery_map.end()) @@ -159,7 +159,7 @@ void AittDiscovery::PublishDiscoveryMsg() true); } -AittDiscovery::DiscoveryBlob::DiscoveryBlob(const void *msg, size_t length) +AittDiscovery::DiscoveryBlob::DiscoveryBlob(const void *msg, int length) : len(length), data(new char[len]) { memcpy(data.get(), msg, length); diff --git a/common/AittDiscovery.h b/common/AittDiscovery.h index 29c3302..3230b92 100644 --- a/common/AittDiscovery.h +++ b/common/AittDiscovery.h @@ -37,19 +37,19 @@ class AittDiscovery { const std::string &password); void Restart(); void Stop(); - void UpdateDiscoveryMsg(const std::string &protocol, const void *msg, size_t length); + void UpdateDiscoveryMsg(const std::string &protocol, const void *msg, int length); int AddDiscoveryCB(const std::string &protocol, const DiscoveryCallback &cb); void RemoveDiscoveryCB(int callback_id); bool CompareTopic(const std::string &left, const std::string &right); private: struct DiscoveryBlob { - explicit DiscoveryBlob(const void *msg, size_t length); + explicit DiscoveryBlob(const void *msg, int length); ~DiscoveryBlob(); DiscoveryBlob(const DiscoveryBlob &src); DiscoveryBlob &operator=(const DiscoveryBlob &src); - size_t len; + int len; std::shared_ptr data; }; diff --git a/common/AittTransport.h b/common/AittTransport.h index 048beeb..1946dee 100644 --- a/common/AittTransport.h +++ b/common/AittTransport.h @@ -32,7 +32,7 @@ class AittTransport { typedef void *( *ModuleEntry)(AittProtocol type, AittDiscovery &discovery, const std::string &my_ip); using SubscribeCallback = std::function; + const int szmsg, void *cbdata, const std::string &correlation)>; static constexpr const char *const MODULE_ENTRY_NAME = DEFINE_TO_STR(AITT_TRANSPORT_NEW); @@ -42,19 +42,15 @@ class AittTransport { } virtual ~AittTransport(void) = default; - virtual void Publish(const std::string &topic, const void *data, const size_t datalen, + virtual void Publish(const std::string &topic, const void *data, const int datalen, const std::string &correlation, AittQoS qos = AITT_QOS_AT_MOST_ONCE, bool retain = false) = 0; - - virtual void Publish(const std::string &topic, const void *data, const size_t datalen, + virtual void Publish(const std::string &topic, const void *data, const int datalen, AittQoS qos = AITT_QOS_AT_MOST_ONCE, bool retain = false) = 0; - virtual void *Subscribe(const std::string &topic, const SubscribeCallback &cb, void *cbdata = nullptr, AittQoS qos = AITT_QOS_AT_MOST_ONCE) = 0; - virtual void *Subscribe(const std::string &topic, const SubscribeCallback &cb, const void *data, - const size_t datalen, void *cbdata = nullptr, AittQoS qos = AITT_QOS_AT_MOST_ONCE) = 0; - virtual void *Unsubscribe(void *handle) = 0; + AittProtocol GetProtocol() { return protocol; } protected: diff --git a/include/AITT.h b/include/AITT.h index eac7556..ead44c9 100644 --- a/include/AITT.h +++ b/include/AITT.h @@ -33,28 +33,28 @@ namespace aitt { class API AITT { public: using SubscribeCallback = - std::function; + std::function; using ConnectionCallback = std::function; explicit AITT(const std::string &id, const std::string &ip_addr, AittOption option = AittOption(false, false)); virtual ~AITT(void); - void SetWillInfo(const std::string &topic, const void *data, const size_t datalen, AittQoS qos, + void SetWillInfo(const std::string &topic, const void *data, const int datalen, AittQoS qos, bool retain); void SetConnectionCallback(ConnectionCallback cb, void *user_data = nullptr); void Connect(const std::string &host = AITT_LOCALHOST, int port = AITT_PORT, const std::string &username = std::string(), const std::string &password = std::string()); void Disconnect(void); - void Publish(const std::string &topic, const void *data, const size_t datalen, + void Publish(const std::string &topic, const void *data, const int datalen, AittProtocol protocols = AITT_TYPE_MQTT, AittQoS qos = AITT_QOS_AT_MOST_ONCE, bool retain = false); - int PublishWithReply(const std::string &topic, const void *data, const size_t datalen, + int PublishWithReply(const std::string &topic, const void *data, const int datalen, AittProtocol protocol, AittQoS qos, bool retain, const SubscribeCallback &cb, void *cbdata, const std::string &correlation); - int PublishWithReplySync(const std::string &topic, const void *data, const size_t datalen, + int PublishWithReplySync(const std::string &topic, const void *data, const int datalen, AittProtocol protocol, AittQoS qos, bool retain, const SubscribeCallback &cb, void *cbdata, const std::string &correlation, int timeout_ms = 0); @@ -63,7 +63,7 @@ class API AITT { AittQoS qos = AITT_QOS_AT_MOST_ONCE); void *Unsubscribe(AittSubscribeID handle); - void SendReply(MSG *msg, const void *data, const size_t datalen, bool end = true); + void SendReply(MSG *msg, const void *data, const int datalen, bool end = true); AittStream *CreateStream(AittStreamProtocol type, const std::string &topic, AittStreamRole role); diff --git a/include/MQ.h b/include/MQ.h index 79d22ae..418cd1a 100644 --- a/include/MQ.h +++ b/include/MQ.h @@ -32,7 +32,7 @@ class MQ { typedef void *(*ModuleEntry)(const char *id, const AittOption &option); using SubscribeCallback = std::function; + const void *data, const int datalen, void *user_data)>; using MQConnectionCallback = std::function; static constexpr const char *const MODULE_ENTRY_NAME = DEFINE_TO_STR(AITT_MQ_NEW); @@ -43,15 +43,14 @@ class MQ { virtual void SetConnectionCallback(const MQConnectionCallback &cb) = 0; virtual void Connect(const std::string &host, int port, const std::string &username, const std::string &password) = 0; - virtual void SetWillInfo(const std::string &topic, const void *msg, size_t szmsg, int qos, + virtual void SetWillInfo(const std::string &topic, const void *msg, int szmsg, int qos, bool retain) = 0; virtual void Disconnect(void) = 0; - virtual void Publish(const std::string &topic, const void *data, const size_t datalen, - int qos = 0, bool retain = false) = 0; - virtual void PublishWithReply(const std::string &topic, const void *data, const size_t datalen, + virtual void Publish(const std::string &topic, const void *data, const int datalen, int qos = 0, + bool retain = false) = 0; + virtual void PublishWithReply(const std::string &topic, const void *data, const int datalen, int qos, bool retain, const std::string &reply_topic, const std::string &correlation) = 0; - virtual void SendReply(MSG *msg, const void *data, const size_t datalen, int qos, - bool retain) = 0; + virtual void SendReply(MSG *msg, const void *data, const int datalen, int qos, bool retain) = 0; virtual void *Subscribe(const std::string &topic, const SubscribeCallback &cb, void *user_data = nullptr, int qos = 0) = 0; virtual void *Unsubscribe(void *handle) = 0; diff --git a/include/aitt_c.h b/include/aitt_c.h index 043d370..a323c3e 100644 --- a/include/aitt_c.h +++ b/include/aitt_c.h @@ -81,8 +81,7 @@ typedef enum AittError aitt_error_e; * @see aitt_subscribe() * @see aitt_subscribe_full() */ -typedef void ( - *aitt_sub_fn)(aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data); +typedef void (*aitt_sub_fn)(aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data); /** * @brief Create a new AITT service instance. @@ -181,7 +180,7 @@ const char *aitt_option_get(aitt_option_h handle, aitt_option_e option); * * @see aitt_connect() */ -int aitt_will_set(aitt_h handle, const char *topic, const void *msg, const size_t msg_len, +int aitt_will_set(aitt_h handle, const char *topic, const void *msg, const int msg_len, aitt_qos_e qos, bool retain); /** @@ -240,7 +239,7 @@ int aitt_disconnect(aitt_h handle); * @retval #AITT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #AITT_ERROR_SYSTEM System errors */ -int aitt_publish(aitt_h handle, const char *topic, const void *msg, const size_t msg_len); +int aitt_publish(aitt_h handle, const char *topic, const void *msg, const int msg_len); /** * @brief Publish a message on a given topic as aitt_publish(), but takes protocols and qos. @@ -257,7 +256,7 @@ int aitt_publish(aitt_h handle, const char *topic, const void *msg, const size_t * @retval #AITT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #AITT_ERROR_SYSTEM System errors */ -int aitt_publish_full(aitt_h handle, const char *topic, const void *msg, const size_t msg_len, +int aitt_publish_full(aitt_h handle, const char *topic, const void *msg, const int msg_len, int protocols, aitt_qos_e qos); /** @@ -279,7 +278,7 @@ int aitt_publish_full(aitt_h handle, const char *topic, const void *msg, const s * @retval #AITT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #AITT_ERROR_SYSTEM System errors */ -int aitt_publish_with_reply(aitt_h handle, const char *topic, const void *msg, const size_t msg_len, +int aitt_publish_with_reply(aitt_h handle, const char *topic, const void *msg, const int msg_len, aitt_protocol_e protocols, aitt_qos_e qos, const char *correlation, aitt_sub_fn cb, void *user_data); @@ -298,7 +297,7 @@ int aitt_publish_with_reply(aitt_h handle, const char *topic, const void *msg, c * @retval #AITT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #AITT_ERROR_SYSTEM System errors */ -int aitt_send_reply(aitt_h handle, aitt_msg_h msg_handle, const void *reply, const size_t reply_len, +int aitt_send_reply(aitt_h handle, aitt_msg_h msg_handle, const void *reply, const int reply_len, bool end); /** diff --git a/modules/tcp/AESEncryptor.cc b/modules/tcp/AESEncryptor.cc index 4c1aa6a..fb3f093 100644 --- a/modules/tcp/AESEncryptor.cc +++ b/modules/tcp/AESEncryptor.cc @@ -43,7 +43,7 @@ void AESEncryptor::Init(const unsigned char *key, const unsigned char *iv) DBG_HEX_DUMP(iv_.data(), iv_.size()); } -size_t AESEncryptor::GetCryptogramSize(size_t plain_size) +int AESEncryptor::GetCryptogramSize(int plain_size) { const int BLOCKSIZE = 16; return (plain_size / BLOCKSIZE + 1) * BLOCKSIZE; @@ -65,7 +65,7 @@ void AESEncryptor::GenerateKey(unsigned char (&key)[AITT_TCP_ENCRYPTOR_KEY_LEN], } } -size_t AESEncryptor::Encrypt(const unsigned char *plaintext, int plaintext_len, +int AESEncryptor::Encrypt(const unsigned char *plaintext, int plaintext_len, unsigned char *ciphertext) { int len; @@ -99,7 +99,7 @@ size_t AESEncryptor::Encrypt(const unsigned char *plaintext, int plaintext_len, return ciphertext_len + len; } -size_t AESEncryptor::Decrypt(const unsigned char *ciphertext, int ciphertext_len, +int AESEncryptor::Decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *plaintext) { int len; diff --git a/modules/tcp/AESEncryptor.h b/modules/tcp/AESEncryptor.h index fc05123..aba8fb5 100644 --- a/modules/tcp/AESEncryptor.h +++ b/modules/tcp/AESEncryptor.h @@ -32,9 +32,9 @@ class AESEncryptor { static void GenerateKey(unsigned char (&key)[AITT_TCP_ENCRYPTOR_KEY_LEN], unsigned char (&iv)[AITT_TCP_ENCRYPTOR_IV_LEN]); void Init(const unsigned char *key, const unsigned char *iv); - size_t GetCryptogramSize(size_t plain_size); - size_t Encrypt(const unsigned char *plaintext, int plaintext_len, unsigned char *ciphertext); - size_t Decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *plaintext); + int GetCryptogramSize(int plain_size); + int Encrypt(const unsigned char *plaintext, int plaintext_len, unsigned char *ciphertext); + int Decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *plaintext); private: std::vector key_; diff --git a/modules/tcp/Module.cc b/modules/tcp/Module.cc index 3246ff7..8476a5f 100644 --- a/modules/tcp/Module.cc +++ b/modules/tcp/Module.cc @@ -61,7 +61,7 @@ void Module::ThreadMain(void) main_loop.Run(); } -void Module::Publish(const std::string &topic, const void *data, const size_t datalen, +void Module::Publish(const std::string &topic, const void *data, const int datalen, const std::string &correlation, AittQoS qos, bool retain) { // NOTE: @@ -120,7 +120,7 @@ void Module::Publish(const std::string &topic, const void *data, const size_t da } try { - size_t length = topic.length(); + int32_t length = topic.length(); portIt->second->SendSizedData(topic.c_str(), length); length = datalen; portIt->second->SendSizedData(data, length); @@ -132,7 +132,7 @@ void Module::Publish(const std::string &topic, const void *data, const size_t da } // publishTable } -void Module::Publish(const std::string &topic, const void *data, const size_t datalen, AittQoS qos, +void Module::Publish(const std::string &topic, const void *data, const int datalen, AittQoS qos, bool retain) { Publish(topic, data, datalen, std::string(), qos, retain); @@ -163,12 +163,6 @@ void *Module::Subscribe(const std::string &topic, const AittTransport::Subscribe return reinterpret_cast(handle); } -void *Module::Subscribe(const std::string &topic, const AittTransport::SubscribeCallback &cb, - const void *data, const size_t datalen, void *cbdata, AittQoS qos) -{ - return nullptr; -} - void *Module::Unsubscribe(void *handlePtr) { int handle = static_cast(reinterpret_cast(handlePtr)); @@ -324,7 +318,7 @@ void Module::ReceiveData(MainLoopHandler::MainLoopResult result, int handle, return impl->HandleClientDisconnect(handle); } - size_t szmsg = 0; + int32_t szmsg = 0; char *msg = nullptr; std::string topic; @@ -371,7 +365,7 @@ void Module::HandleClientDisconnect(int handle) std::string Module::GetTopicName(Module::TCPData *tcp_data) { - size_t topic_length = 0; + int32_t topic_length = 0; void *topic_data = nullptr; int ret = tcp_data->client->RecvSizedData(&topic_data, topic_length); if (ret < 0) { @@ -385,7 +379,7 @@ std::string Module::GetTopicName(Module::TCPData *tcp_data) } std::string topic = std::string(static_cast(topic_data), topic_length); - INFO("Complete topic = [%s], topic_len = %zu", topic.c_str(), topic_length); + INFO("Complete topic = [%s], topic_len = %d", topic.c_str(), topic_length); free(topic_data); return topic; diff --git a/modules/tcp/Module.h b/modules/tcp/Module.h index 7a53edd..21aca50 100644 --- a/modules/tcp/Module.h +++ b/modules/tcp/Module.h @@ -39,19 +39,14 @@ class Module : public AittTransport { explicit Module(AittProtocol type, AittDiscovery &discovery, const std::string &ip); virtual ~Module(void); - void Publish(const std::string &topic, const void *data, const size_t datalen, + void Publish(const std::string &topic, const void *data, const int datalen, const std::string &correlation, AittQoS qos = AITT_QOS_AT_MOST_ONCE, bool retain = false) override; - - void Publish(const std::string &topic, const void *data, const size_t datalen, + void Publish(const std::string &topic, const void *data, const int datalen, AittQoS qos = AITT_QOS_AT_MOST_ONCE, bool retain = false) override; void *Subscribe(const std::string &topic, const SubscribeCallback &cb, void *cbdata = nullptr, AittQoS qos = AITT_QOS_AT_MOST_ONCE) override; - - void *Subscribe(const std::string &topic, const SubscribeCallback &cb, const void *data, - const size_t datalen, void *cbdata = nullptr, - AittQoS qos = AITT_QOS_AT_MOST_ONCE) override; void *Unsubscribe(void *handle) override; private: diff --git a/modules/tcp/TCP.cc b/modules/tcp/TCP.cc index d291b39..26d2c32 100644 --- a/modules/tcp/TCP.cc +++ b/modules/tcp/TCP.cc @@ -114,22 +114,22 @@ void TCP::SetupOptions(const ConnectInfo &connect_info) } } -void TCP::Send(const void *data, size_t &szData) +void TCP::Send(const void *data, int32_t &data_size) { - size_t sent = 0; - while (sent < szData) { - int ret = send(handle, static_cast(data) + sent, szData - sent, 0); + int32_t sent = 0; + while (sent < data_size) { + int ret = send(handle, static_cast(data) + sent, data_size - sent, 0); if (ret < 0) { - ERR("Fail to send data, handle = %d, size = %zu", handle, szData); + ERR("Fail to send data, handle = %d, size = %d", handle, data_size); throw std::runtime_error(strerror(errno)); } sent += ret; } - szData = sent; + data_size = sent; } -void TCP::SendSizedData(const void *data, size_t &szData) +void TCP::SendSizedData(const void *data, int32_t &szData) { if (secure) SendSizedDataSecure(data, szData); @@ -137,13 +137,13 @@ void TCP::SendSizedData(const void *data, size_t &szData) SendSizedDataNormal(data, szData); } -int TCP::Recv(void *data, size_t &szData) +int TCP::Recv(void *data, int32_t &data_size) { - size_t received = 0; - while (received < szData) { - int ret = recv(handle, static_cast(data) + received, szData - received, 0); + int32_t received = 0; + while (received < data_size) { + int ret = recv(handle, static_cast(data) + received, data_size - received, 0); if (ret < 0) { - ERR("Fail to recv data, handle = %d, size = %zu", handle, szData); + ERR("Fail to recv data, handle = %d, size = %d", handle, data_size); throw std::runtime_error(strerror(errno)); } if (ret == 0) { @@ -154,11 +154,11 @@ int TCP::Recv(void *data, size_t &szData) received += ret; } - szData = received; + data_size = received; return 0; } -int TCP::RecvSizedData(void **data, size_t &szData) +int TCP::RecvSizedData(void **data, int32_t &szData) { if (secure) return RecvSizedDataSecure(data, szData); @@ -166,7 +166,7 @@ int TCP::RecvSizedData(void **data, size_t &szData) return RecvSizedDataNormal(data, szData); } -int TCP::HandleZeroMsg(void **data, size_t &data_size) +int TCP::HandleZeroMsg(void **data, int32_t &data_size) { // distinguish between connection problems and zero-size messages INFO("Got a zero-size message."); @@ -205,37 +205,37 @@ unsigned short TCP::GetPort(void) return ntohs(addr.sin_port); } -void TCP::SendSizedDataNormal(const void *data, size_t &data_size) +void TCP::SendSizedDataNormal(const void *data, int32_t &data_size) { - size_t fixed_data_size = data_size; + int32_t fixed_data_size = data_size; if (0 == data_size) { // distinguish between connection problems and zero-size messages INFO("Send a zero-size message."); - fixed_data_size = UINT32_MAX; + fixed_data_size = INT32_MAX; } - size_t size_len = sizeof(fixed_data_size); + int32_t size_len = sizeof(fixed_data_size); Send(static_cast(&fixed_data_size), size_len); Send(data, data_size); } -int TCP::RecvSizedDataNormal(void **data, size_t &data_size) +int TCP::RecvSizedDataNormal(void **data, int32_t &data_size) { int ret; - size_t data_len = 0; - size_t size_len = sizeof(data_len); + int32_t data_len = 0; + int32_t size_len = sizeof(data_len); ret = Recv(static_cast(&data_len), size_len); if (ret < 0) { ERR("Recv() Fail(%d)", ret); return ret; } - if (data_len == UINT32_MAX) + if (data_len == INT32_MAX) return HandleZeroMsg(data, data_size); if (AITT_MESSAGE_MAX < data_len) { - ERR("Invalid Size(%zu)", data_len); + ERR("Invalid Size(%d)", data_len); return -1; } void *data_buf = malloc(data_len); @@ -246,37 +246,37 @@ int TCP::RecvSizedDataNormal(void **data, size_t &data_size) return 0; } -void TCP::SendSizedDataSecure(const void *data, size_t &data_size) +void TCP::SendSizedDataSecure(const void *data, int32_t &data_size) { - size_t fixed_data_size = data_size; + int32_t fixed_data_size = data_size; if (0 == data_size) { // distinguish between connection problems and zero-size messages INFO("Send a zero-size message."); - fixed_data_size = UINT32_MAX; + fixed_data_size = INT32_MAX; } - size_t size_len; + int32_t size_len; if (data_size) { unsigned char data_buf[crypto.GetCryptogramSize(data_size)]; - size_t data_len = + int32_t data_len = crypto.Encrypt(static_cast(data), data_size, data_buf); - unsigned char size_buf[crypto.GetCryptogramSize(sizeof(size_t))]; + unsigned char size_buf[crypto.GetCryptogramSize(sizeof(int32_t))]; size_len = crypto.Encrypt((unsigned char *)&data_len, sizeof(data_len), size_buf); Send(size_buf, size_len); Send(data_buf, data_len); } else { - unsigned char size_buf[crypto.GetCryptogramSize(sizeof(size_t))]; + unsigned char size_buf[crypto.GetCryptogramSize(sizeof(int32_t))]; size_len = crypto.Encrypt((unsigned char *)&fixed_data_size, sizeof(fixed_data_size), size_buf); Send(size_buf, size_len); } } -int TCP::RecvSizedDataSecure(void **data, size_t &data_size) +int TCP::RecvSizedDataSecure(void **data, int32_t &data_size) { int ret; - size_t cipher_size_len = crypto.GetCryptogramSize(sizeof(size_t)); + int32_t cipher_size_len = crypto.GetCryptogramSize(sizeof(int32_t)); unsigned char cipher_size_buf[cipher_size_len]; ret = Recv(cipher_size_buf, cipher_size_len); if (ret < 0) { @@ -285,14 +285,14 @@ int TCP::RecvSizedDataSecure(void **data, size_t &data_size) } unsigned char plain_size_buf[cipher_size_len]; - size_t cipher_data_len = 0; + int32_t cipher_data_len = 0; crypto.Decrypt(cipher_size_buf, cipher_size_len, plain_size_buf); memcpy(&cipher_data_len, plain_size_buf, sizeof(cipher_data_len)); - if (cipher_data_len == UINT32_MAX) + if (cipher_data_len == INT32_MAX) return HandleZeroMsg(data, data_size); if (AITT_MESSAGE_MAX < cipher_data_len) { - ERR("Invalid Size(%zu)", cipher_data_len); + ERR("Invalid Size(%d)", cipher_data_len); return -1; } unsigned char cipher_data_buf[cipher_data_len]; diff --git a/modules/tcp/TCP.h b/modules/tcp/TCP.h index eac67af..6d73a4a 100644 --- a/modules/tcp/TCP.h +++ b/modules/tcp/TCP.h @@ -15,8 +15,8 @@ */ #pragma once +#include #include -#include /* See NOTES */ #include @@ -45,10 +45,10 @@ class TCP { TCP(const std::string &host, const ConnectInfo &ConnectInfo); virtual ~TCP(void); - void Send(const void *data, size_t &szData); - void SendSizedData(const void *data, size_t &szData); - int Recv(void *data, size_t &szData); - int RecvSizedData(void **data, size_t &szData); + void Send(const void *data, int32_t &szData); + void SendSizedData(const void *data, int32_t &szData); + int Recv(void *data, int32_t &szData); + int RecvSizedData(void **data, int32_t &szData); int GetHandle(void); unsigned short GetPort(void); void GetPeerInfo(std::string &host, unsigned short &port); @@ -56,11 +56,11 @@ class TCP { private: TCP(int handle, sockaddr *addr, socklen_t addrlen, const ConnectInfo &connect_info); void SetupOptions(const ConnectInfo &connect_info); - int HandleZeroMsg(void **data, size_t &data_size); - void SendSizedDataNormal(const void *data, size_t &data_size); - int RecvSizedDataNormal(void **data, size_t &data_size); - void SendSizedDataSecure(const void *data, size_t &data_size); - int RecvSizedDataSecure(void **data, size_t &data_size); + int HandleZeroMsg(void **data, int32_t &data_size); + void SendSizedDataNormal(const void *data, int32_t &data_size); + int RecvSizedDataNormal(void **data, int32_t &data_size); + void SendSizedDataSecure(const void *data, int32_t &data_size); + int RecvSizedDataSecure(void **data, int32_t &data_size); int handle; socklen_t addrlen; diff --git a/modules/tcp/samples/tcp_test.cc b/modules/tcp/samples/tcp_test.cc index 9bdca5c..4ffe1e1 100644 --- a/modules/tcp/samples/tcp_test.cc +++ b/modules/tcp/samples/tcp_test.cc @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include +#include "../TCP.h" + #include #include @@ -23,6 +23,8 @@ #include #include +#include "../TCPServer.h" + //#define _LOG_WITH_TIMESTAMP #include "aitt_internal.h" #ifdef _LOG_WITH_TIMESTAMP @@ -145,7 +147,7 @@ int main(int argc, char *argv[]) char buffer[10]; void *ptr = static_cast(buffer); - size_t szData = sizeof(HELLO_STRING); + int32_t szData = sizeof(HELLO_STRING); peer->Recv(ptr, szData); INFO("Gots[%s]", buffer); @@ -211,7 +213,7 @@ int main(int argc, char *argv[]) INFO("Assigned client port: %u", client->GetPort()); INFO("Send[%s]", HELLO_STRING); - size_t szBuffer = sizeof(HELLO_STRING); + int32_t szBuffer = sizeof(HELLO_STRING); client->Send(HELLO_STRING, szBuffer); char buffer[10]; diff --git a/modules/tcp/tests/AESEncryptor_test.cc b/modules/tcp/tests/AESEncryptor_test.cc index a5a45d1..27b3509 100644 --- a/modules/tcp/tests/AESEncryptor_test.cc +++ b/modules/tcp/tests/AESEncryptor_test.cc @@ -53,9 +53,8 @@ TEST(AESEncryptor, EncryptDecryped_P_Anytime) unsigned char ciphertext[encryptor.GetCryptogramSize(TEST_MESSAGE.size())]; unsigned char plaintext[encryptor.GetCryptogramSize(TEST_MESSAGE.size())]; - size_t len = - encryptor.Encrypt(reinterpret_cast(TEST_MESSAGE.c_str()), - TEST_MESSAGE.size(), ciphertext); + int len = encryptor.Encrypt(reinterpret_cast(TEST_MESSAGE.c_str()), + TEST_MESSAGE.size(), ciphertext); len = encryptor.Decrypt(ciphertext, len, plaintext); plaintext[len] = 0; ASSERT_STREQ(TEST_MESSAGE.c_str(), reinterpret_cast(plaintext)); diff --git a/modules/tcp/tests/TCP_test.cc b/modules/tcp/tests/TCP_test.cc index 0811ca4..ad785ec 100644 --- a/modules/tcp/tests/TCP_test.cc +++ b/modules/tcp/tests/TCP_test.cc @@ -135,7 +135,7 @@ TEST_F(TCPTest, SendRecv_P_Anytime) char byeBuffer[TEST_BUFFER_SIZE]; customTest = [this, &helloBuffer](void) mutable -> void { - size_t szData = sizeof(TEST_BUFFER_HELLO); + int32_t szData = sizeof(TEST_BUFFER_HELLO); client->Recv(static_cast(helloBuffer), szData); szData = sizeof(TEST_BUFFER_BYE); @@ -144,7 +144,7 @@ TEST_F(TCPTest, SendRecv_P_Anytime) RunServer(); - size_t szMsg = sizeof(TEST_BUFFER_HELLO); + int32_t szMsg = sizeof(TEST_BUFFER_HELLO); peer->Send(TEST_BUFFER_HELLO, szMsg); szMsg = sizeof(TEST_BUFFER_BYE); diff --git a/modules/webrtc/Module.cc b/modules/webrtc/Module.cc index 054b278..371c478 100644 --- a/modules/webrtc/Module.cc +++ b/modules/webrtc/Module.cc @@ -45,7 +45,7 @@ void Module::SetConfig(const std::string &key, void *obj) } void Module::Start(void) -{ +{ } void Module::SetStateCallback(StateCallback cb, void *user_data) diff --git a/packaging/aitt.spec b/packaging/aitt.spec index 690bf14..710cd32 100644 --- a/packaging/aitt.spec +++ b/packaging/aitt.spec @@ -71,7 +71,7 @@ cp %{SOURCE1001} . -DLOG_STDOUT:BOOL=%{stdoutlog} \ -DPLATFORM="tizen" \ -DVERSIONING:BOOL=OFF \ - -DWITH_WEBRTC:BOOL=ON \ + -DWITH_WEBRTC:BOOL=OFF \ -DWITH_RTSP:BOOL=ON \ -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \ -DCMAKE_VERBOSE_MAKEFILE=OFF \ diff --git a/src/AITT.cc b/src/AITT.cc index 36d0437..83cf273 100644 --- a/src/AITT.cc +++ b/src/AITT.cc @@ -49,8 +49,8 @@ AITT::~AITT(void) { } -void AITT::SetWillInfo(const std::string &topic, const void *data, const size_t datalen, - AittQoS qos, bool retain) +void AITT::SetWillInfo(const std::string &topic, const void *data, const int datalen, AittQoS qos, + bool retain) { return pImpl->SetWillInfo(topic, data, datalen, qos, retain); } @@ -71,23 +71,23 @@ void AITT::Disconnect(void) return pImpl->Disconnect(); } -void AITT::Publish(const std::string &topic, const void *data, const size_t datalen, +void AITT::Publish(const std::string &topic, const void *data, const int datalen, AittProtocol protocols, AittQoS qos, bool retain) { if (AITT_PAYLOAD_MAX < datalen) { - ERR("Invalid Size(%zu)", datalen); + ERR("Invalid Size(%d)", datalen); throw std::runtime_error("Invalid Size"); } return pImpl->Publish(topic, data, datalen, protocols, qos, retain); } -int AITT::PublishWithReply(const std::string &topic, const void *data, const size_t datalen, +int AITT::PublishWithReply(const std::string &topic, const void *data, const int datalen, AittProtocol protocol, AittQoS qos, bool retain, const SubscribeCallback &cb, void *cbdata, const std::string &correlation) { if (AITT_PAYLOAD_MAX < datalen) { - ERR("Invalid Size(%zu)", datalen); + ERR("Invalid Size(%d)", datalen); throw std::runtime_error("Invalid Size"); } @@ -95,12 +95,12 @@ int AITT::PublishWithReply(const std::string &topic, const void *data, const siz correlation); } -int AITT::PublishWithReplySync(const std::string &topic, const void *data, const size_t datalen, +int AITT::PublishWithReplySync(const std::string &topic, const void *data, const int datalen, AittProtocol protocol, AittQoS qos, bool retain, const SubscribeCallback &cb, void *cbdata, const std::string &correlation, int timeout_ms) { if (AITT_PAYLOAD_MAX < datalen) { - ERR("Invalid Size(%zu)", datalen); + ERR("Invalid Size(%d)", datalen); throw std::runtime_error("Invalid Size"); } @@ -119,10 +119,10 @@ void *AITT::Unsubscribe(AittSubscribeID handle) return pImpl->Unsubscribe(handle); } -void AITT::SendReply(MSG *msg, const void *data, size_t datalen, bool end) +void AITT::SendReply(MSG *msg, const void *data, int datalen, bool end) { if (AITT_PAYLOAD_MAX < datalen) { - ERR("Invalid Size(%zu)", datalen); + ERR("Invalid Size(%d)", datalen); throw std::runtime_error("Invalid Size"); } diff --git a/src/AITTImpl.cc b/src/AITTImpl.cc index 821c339..025f2fd 100644 --- a/src/AITTImpl.cc +++ b/src/AITTImpl.cc @@ -75,7 +75,7 @@ void AITT::Impl::ThreadMain(void) main_loop.Run(); } -void AITT::Impl::SetWillInfo(const std::string &topic, const void *data, const size_t datalen, +void AITT::Impl::SetWillInfo(const std::string &topic, const void *data, const int datalen, AittQoS qos, bool retain) { mq->SetWillInfo(topic, data, datalen, qos, retain); @@ -151,7 +151,7 @@ void AITT::Impl::ConfigureTransportModule(const std::string &key, const std::str { } -void AITT::Impl::Publish(const std::string &topic, const void *data, const size_t datalen, +void AITT::Impl::Publish(const std::string &topic, const void *data, const int datalen, AittProtocol protocols, AittQoS qos, bool retain) { if ((protocols & AITT_TYPE_MQTT) == AITT_TYPE_MQTT) @@ -200,7 +200,7 @@ AittSubscribeID AITT::Impl::SubscribeMQ(SubscribeInfo *handle, MainLoopHandler * return mq->Subscribe( topic, [this, handle, loop_handle, cb](MSG *msg, const std::string &topic, const void *data, - const size_t datalen, void *mq_user_data) { + const int datalen, void *mq_user_data) { void *delivery = malloc(datalen); if (delivery) memcpy(delivery, data, datalen); @@ -214,7 +214,7 @@ AittSubscribeID AITT::Impl::SubscribeMQ(SubscribeInfo *handle, MainLoopHandler * user_data, qos); } -void AITT::Impl::DetachedCB(SubscribeCallback cb, MSG msg, void *data, const size_t datalen, +void AITT::Impl::DetachedCB(SubscribeCallback cb, MSG msg, void *data, const int datalen, void *user_data, MainLoopHandler::MainLoopResult result, int fd, MainLoopHandler::MainLoopData *loop_data) { @@ -260,7 +260,7 @@ void *AITT::Impl::Unsubscribe(AittSubscribeID subscribe_id) return user_data; } -int AITT::Impl::PublishWithReply(const std::string &topic, const void *data, const size_t datalen, +int AITT::Impl::PublishWithReply(const std::string &topic, const void *data, const int datalen, AittProtocol protocol, AittQoS qos, bool retain, const SubscribeCallback &cb, void *user_data, const std::string &correlation) { @@ -271,8 +271,7 @@ int AITT::Impl::PublishWithReply(const std::string &topic, const void *data, con Subscribe( replyTopic, - [this, cb](MSG *sub_msg, const void *sub_data, const size_t sub_datalen, - void *sub_cbdata) { + [this, cb](MSG *sub_msg, const void *sub_data, const int sub_datalen, void *sub_cbdata) { if (sub_msg->IsEndSequence()) { try { Unsubscribe(sub_msg->GetID()); @@ -288,9 +287,9 @@ int AITT::Impl::PublishWithReply(const std::string &topic, const void *data, con return 0; } -int AITT::Impl::PublishWithReplySync(const std::string &topic, const void *data, - const size_t datalen, AittProtocol protocol, AittQoS qos, bool retain, - const SubscribeCallback &cb, void *user_data, const std::string &correlation, int timeout_ms) +int AITT::Impl::PublishWithReplySync(const std::string &topic, const void *data, const int datalen, + AittProtocol protocol, AittQoS qos, bool retain, const SubscribeCallback &cb, void *user_data, + const std::string &correlation, int timeout_ms) { std::string replyTopic = topic + RESPONSE_POSTFIX + std::to_string(reply_id++); @@ -307,7 +306,7 @@ int AITT::Impl::PublishWithReplySync(const std::string &topic, const void *data, subscribe_handle = SubscribeMQ( info, &sync_loop, replyTopic, - [&](MSG *sub_msg, const void *sub_data, const size_t sub_datalen, void *sub_cbdata) { + [&](MSG *sub_msg, const void *sub_data, const int sub_datalen, void *sub_cbdata) { if (sub_msg->IsEndSequence()) { try { Unsubscribe(sub_msg->GetID()); @@ -375,7 +374,7 @@ void *AITT::Impl::SubscribeTCP(SubscribeInfo *handle, const std::string &topic, return modules.Get(handle->first) .Subscribe( topic, - [handle, cb](const std::string &topic, const void *data, const size_t datalen, + [handle, cb](const std::string &topic, const void *data, const int datalen, void *user_data, const std::string &correlation) -> void { MSG msg; msg.SetID(handle); diff --git a/src/AITTImpl.h b/src/AITTImpl.h index 7279687..b902e50 100644 --- a/src/AITTImpl.h +++ b/src/AITTImpl.h @@ -36,7 +36,7 @@ class AITT::Impl { const AittOption &option); virtual ~Impl(void); - void SetWillInfo(const std::string &topic, const void *data, const size_t datalen, AittQoS qos, + void SetWillInfo(const std::string &topic, const void *data, const int datalen, AittQoS qos, bool retain); void SetConnectionCallback(ConnectionCallback cb, void *user_data); void Connect(const std::string &host, int port, const std::string &username, @@ -46,12 +46,12 @@ class AITT::Impl { void ConfigureTransportModule(const std::string &key, const std::string &value, AittProtocol protocols); - void Publish(const std::string &topic, const void *data, const size_t datalen, + void Publish(const std::string &topic, const void *data, const int datalen, AittProtocol protocols, AittQoS qos, bool retain); - int PublishWithReply(const std::string &topic, const void *data, const size_t datalen, + int PublishWithReply(const std::string &topic, const void *data, const int datalen, AittProtocol protocol, AittQoS qos, bool retain, const AITT::SubscribeCallback &cb, void *cbdata, const std::string &correlation); - int PublishWithReplySync(const std::string &topic, const void *data, const size_t datalen, + int PublishWithReplySync(const std::string &topic, const void *data, const int datalen, AittProtocol protocol, AittQoS qos, bool retain, const SubscribeCallback &cb, void *cbdata, const std::string &correlation, int timeout_ms); @@ -72,9 +72,8 @@ class AITT::Impl { void ConnectionCB(ConnectionCallback cb, void *user_data, int status); AittSubscribeID SubscribeMQ(SubscribeInfo *info, MainLoopHandler *loop_handle, const std::string &topic, const SubscribeCallback &cb, void *cbdata, AittQoS qos); - void DetachedCB(SubscribeCallback cb, MSG mq_msg, void *data, const size_t datalen, - void *cbdata, MainLoopHandler::MainLoopResult result, int fd, - MainLoopHandler::MainLoopData *loop_data); + void DetachedCB(SubscribeCallback cb, MSG mq_msg, void *data, const int datalen, void *cbdata, + MainLoopHandler::MainLoopResult result, int fd, MainLoopHandler::MainLoopData *loop_data); void *SubscribeTCP(SubscribeInfo *, const std::string &topic, const SubscribeCallback &cb, void *cbdata, AittQoS qos); diff --git a/src/MosquittoMQ.cc b/src/MosquittoMQ.cc index 4950e96..ada7de3 100644 --- a/src/MosquittoMQ.cc +++ b/src/MosquittoMQ.cc @@ -147,7 +147,7 @@ void MosquittoMQ::Connect(const std::string &host, int port, const std::string & } } -void MosquittoMQ::SetWillInfo(const std::string &topic, const void *msg, size_t szmsg, int qos, +void MosquittoMQ::SetWillInfo(const std::string &topic, const void *msg, int szmsg, int qos, bool retain) { int ret = mosquitto_will_set(handle, topic.c_str(), szmsg, msg, qos, retain); @@ -259,7 +259,7 @@ void MosquittoMQ::InvokeCallback(SubscribeData *subscriber, const mosquitto_mess subscriber->cb(&mq_msg, msg->topic, msg->payload, msg->payloadlen, subscriber->user_data); } -void MosquittoMQ::Publish(const std::string &topic, const void *data, const size_t datalen, int qos, +void MosquittoMQ::Publish(const std::string &topic, const void *data, const int datalen, int qos, bool retain) { int mid = -1; @@ -270,7 +270,7 @@ void MosquittoMQ::Publish(const std::string &topic, const void *data, const size } } -void MosquittoMQ::PublishWithReply(const std::string &topic, const void *data, const size_t datalen, +void MosquittoMQ::PublishWithReply(const std::string &topic, const void *data, const int datalen, int qos, bool retain, const std::string &reply_topic, const std::string &correlation) { int ret; @@ -296,7 +296,7 @@ void MosquittoMQ::PublishWithReply(const std::string &topic, const void *data, c } } -void MosquittoMQ::SendReply(MSG *msg, const void *data, const size_t datalen, int qos, bool retain) +void MosquittoMQ::SendReply(MSG *msg, const void *data, const int datalen, int qos, bool retain) { RET_IF(msg == nullptr); diff --git a/src/MosquittoMQ.h b/src/MosquittoMQ.h index f900b8f..38c6e48 100644 --- a/src/MosquittoMQ.h +++ b/src/MosquittoMQ.h @@ -38,13 +38,13 @@ class MosquittoMQ : public MQ { void SetConnectionCallback(const MQConnectionCallback &cb); void Connect(const std::string &host, int port, const std::string &username, const std::string &password); - void SetWillInfo(const std::string &topic, const void *msg, size_t szmsg, int qos, bool retain); + void SetWillInfo(const std::string &topic, const void *msg, int szmsg, int qos, bool retain); void Disconnect(void); - void Publish(const std::string &topic, const void *data, const size_t datalen, int qos = 0, + void Publish(const std::string &topic, const void *data, const int datalen, int qos = 0, bool retain = false); - void PublishWithReply(const std::string &topic, const void *data, const size_t datalen, int qos, + void PublishWithReply(const std::string &topic, const void *data, const int datalen, int qos, bool retain, const std::string &reply_topic, const std::string &correlation); - void SendReply(MSG *msg, const void *data, const size_t datalen, int qos, bool retain); + void SendReply(MSG *msg, const void *data, const int datalen, int qos, bool retain); void *Subscribe(const std::string &topic, const SubscribeCallback &cb, void *user_data = nullptr, int qos = 0); void *Unsubscribe(void *handle); diff --git a/src/NullTransport.cc b/src/NullTransport.cc index e5b46db..5890ce8 100644 --- a/src/NullTransport.cc +++ b/src/NullTransport.cc @@ -22,12 +22,12 @@ NullTransport::NullTransport(AittDiscovery& discovery, const std::string& ip) { } -void NullTransport::Publish(const std::string& topic, const void* data, const size_t datalen, +void NullTransport::Publish(const std::string& topic, const void* data, const int datalen, const std::string& correlation, AittQoS qos, bool retain) { } -void NullTransport::Publish(const std::string& topic, const void* data, const size_t datalen, +void NullTransport::Publish(const std::string& topic, const void* data, const int datalen, AittQoS qos, bool retain) { } @@ -38,12 +38,6 @@ void* NullTransport::Subscribe(const std::string& topic, const SubscribeCallback return nullptr; } -void* NullTransport::Subscribe(const std::string& topic, const SubscribeCallback& cb, - const void* data, const size_t datalen, void* cbdata, AittQoS qos) -{ - return nullptr; -} - void* NullTransport::Unsubscribe(void* handle) { return nullptr; diff --git a/src/NullTransport.h b/src/NullTransport.h index e283705..eedc954 100644 --- a/src/NullTransport.h +++ b/src/NullTransport.h @@ -24,19 +24,15 @@ class NullTransport : public AittTransport { explicit NullTransport(AittDiscovery &discovery, const std::string &ip); virtual ~NullTransport(void) = default; - void Publish(const std::string &topic, const void *data, const size_t datalen, + void Publish(const std::string &topic, const void *data, const int datalen, const std::string &correlation, AittQoS qos = AITT_QOS_AT_MOST_ONCE, bool retain = false) override; - void Publish(const std::string &topic, const void *data, const size_t datalen, + void Publish(const std::string &topic, const void *data, const int datalen, AittQoS qos = AITT_QOS_AT_MOST_ONCE, bool retain = false) override; void *Subscribe(const std::string &topic, const SubscribeCallback &cb, void *cbdata = nullptr, AittQoS qos = AITT_QOS_AT_MOST_ONCE) override; - void *Subscribe(const std::string &topic, const SubscribeCallback &cb, const void *data, - const size_t datalen, void *cbdata = nullptr, - AittQoS qos = AITT_QOS_AT_MOST_ONCE) override; - void *Unsubscribe(void *handle) override; }; diff --git a/src/aitt_c.cc b/src/aitt_c.cc index 4ff6363..ce25391 100644 --- a/src/aitt_c.cc +++ b/src/aitt_c.cc @@ -169,7 +169,7 @@ API const char *aitt_option_get(aitt_option_h handle, aitt_option_e option) return nullptr; } -API int aitt_will_set(aitt_h handle, const char *topic, const void *msg, const size_t msg_len, +API int aitt_will_set(aitt_h handle, const char *topic, const void *msg, const int msg_len, aitt_qos_e qos, bool retain) { RETV_IF(handle == nullptr, AITT_ERROR_INVALID_PARAMETER); @@ -177,7 +177,7 @@ API int aitt_will_set(aitt_h handle, const char *topic, const void *msg, const s try { handle->aitt->SetWillInfo(topic, msg, msg_len, qos, retain); } catch (std::exception &e) { - ERR("SetWillInfo(%s, %zu) Fail(%s)", topic, msg_len, e.what()); + ERR("SetWillInfo(%s, %d) Fail(%s)", topic, msg_len, e.what()); return AITT_ERROR_SYSTEM; } return AITT_ERROR_NONE; @@ -235,12 +235,12 @@ API int aitt_disconnect(aitt_h handle) return AITT_ERROR_NONE; } -API int aitt_publish(aitt_h handle, const char *topic, const void *msg, const size_t msg_len) +API int aitt_publish(aitt_h handle, const char *topic, const void *msg, const int msg_len) { return aitt_publish_full(handle, topic, msg, msg_len, AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE); } -API int aitt_publish_full(aitt_h handle, const char *topic, const void *msg, const size_t msg_len, +API int aitt_publish_full(aitt_h handle, const char *topic, const void *msg, const int msg_len, int protocols, aitt_qos_e qos) { RETV_IF(handle == nullptr, AITT_ERROR_INVALID_PARAMETER); @@ -252,7 +252,7 @@ API int aitt_publish_full(aitt_h handle, const char *topic, const void *msg, con try { handle->aitt->Publish(topic, msg, msg_len, AITT_TYPE_MQTT); } catch (std::exception &e) { - ERR("Publish(topic:%s, msg_len:%zu) Fail(%s)", topic, msg_len, e.what()); + ERR("Publish(topic:%s, msg_len:%d) Fail(%s)", topic, msg_len, e.what()); return AITT_ERROR_SYSTEM; } @@ -260,7 +260,7 @@ API int aitt_publish_full(aitt_h handle, const char *topic, const void *msg, con } API int aitt_publish_with_reply(aitt_h handle, const char *topic, const void *msg, - const size_t msg_len, aitt_protocol_e protocols, aitt_qos_e qos, const char *correlation, + const int msg_len, aitt_protocol_e protocols, aitt_qos_e qos, const char *correlation, aitt_sub_fn cb, void *user_data) { RETV_IF(handle == nullptr, AITT_ERROR_INVALID_PARAMETER); @@ -282,7 +282,7 @@ API int aitt_publish_with_reply(aitt_h handle, const char *topic, const void *ms } API int aitt_send_reply(aitt_h handle, aitt_msg_h msg_handle, const void *reply, - const size_t reply_len, bool end) + const int reply_len, bool end) { try { aitt::MSG *msg = static_cast(msg_handle); diff --git a/tests/AITT_TCP_test.cc b/tests/AITT_TCP_test.cc index ed72da4..054e3f5 100644 --- a/tests/AITT_TCP_test.cc +++ b/tests/AITT_TCP_test.cc @@ -40,10 +40,9 @@ class AITTTCPTest : public testing::Test, public AittTests { int cnt = 0; aitt.Subscribe( "test/+", - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, - void *cbdata) -> void { + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTCPTest *test = static_cast(cbdata); - INFO("Got Message(Topic:%s, size:%zu)", handle->GetTopic().c_str(), szmsg); + INFO("Got Message(Topic:%s, size:%d)", handle->GetTopic().c_str(), szmsg); ++cnt; std::stringstream ss; @@ -84,9 +83,9 @@ TEST_F(AITTTCPTest, TCP_Wildcards1_Anytime) aitt.Subscribe( "test/#", - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void { + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTCPTest *test = static_cast(cbdata); - INFO("Got Message(Topic:%s, size:%zu)", handle->GetTopic().c_str(), szmsg); + INFO("Got Message(Topic:%s, size:%d)", handle->GetTopic().c_str(), szmsg); static int cnt = 0; ++cnt; if (cnt == 3) diff --git a/tests/AITT_manualtest.cc b/tests/AITT_manualtest.cc index 42b3c23..c20a316 100644 --- a/tests/AITT_manualtest.cc +++ b/tests/AITT_manualtest.cc @@ -36,10 +36,10 @@ TEST_F(AITTManualTest, WillSet_P) aitt.Connect(); aitt.Subscribe( "test/AITT_will", - [](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void { + [](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTManualTest *test = static_cast(cbdata); test->ToggleReady(); - DBG("Subscribe invoked: %s %zu", static_cast(msg), szmsg); + DBG("Subscribe invoked: %s %d", static_cast(msg), szmsg); }, static_cast(this)); diff --git a/tests/AITT_test.cc b/tests/AITT_test.cc index 30f6eef..e0cf13d 100644 --- a/tests/AITT_test.cc +++ b/tests/AITT_test.cc @@ -37,13 +37,13 @@ class AITTTest : public testing::Test, public AittTests { aitt.Connect(); aitt.Subscribe( testTopic, - [](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void { + [](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTest *test = static_cast(cbdata); test->ToggleReady(); if (msg) - DBG("Subscribe invoked: %s %zu", static_cast(msg), szmsg); + DBG("Subscribe invoked: %s %d", static_cast(msg), szmsg); else - DBG("Subscribe invoked: zero size msg(%zu)", szmsg); + DBG("Subscribe invoked: zero size msg(%d)", szmsg); }, static_cast(this), protocol); @@ -85,8 +85,7 @@ class AITTTest : public testing::Test, public AittTests { int cnt = 0; aitt.Subscribe( TEST_STRESS_TOPIC, - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, - void *cbdata) -> void { + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTest *test = static_cast(cbdata); ++cnt; if (szmsg == 0 && cnt != 12) { @@ -154,14 +153,13 @@ class AITTTest : public testing::Test, public AittTests { int cnt = 0; aitt.Subscribe( testTopic, - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, - void *cbdata) -> void { + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTest *test = static_cast(cbdata); // NOTE: // Subscribe callback will be invoked 2 times ++cnt; const char *receivedMsg = static_cast(msg); - DBG("Subscribe callback called: %d, szmsg = %zu, msg = [%s]", cnt, szmsg, + DBG("Subscribe callback called: %d, szmsg = %d, msg = [%s]", cnt, szmsg, receivedMsg); if (cnt == 1) { ASSERT_TRUE(!strcmp(receivedMsg, TEST_MSG)); @@ -202,8 +200,7 @@ class AITTTest : public testing::Test, public AittTests { int cnt = 0; aitt.Subscribe( testTopic, - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, - void *cbdata) -> void { + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTest *test = static_cast(cbdata); ++cnt; if (cnt == 1) @@ -391,7 +388,7 @@ TEST_F(AITTTest, Unsubscribe_MQTT_P_Anytime) aitt.Connect(); subscribeHandle = aitt.Subscribe( testTopic, - [](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void {}, + [](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void {}, nullptr, AITT_TYPE_MQTT); DBG(">>> Handle: %p", reinterpret_cast(subscribeHandle)); aitt.Unsubscribe(subscribeHandle); @@ -407,7 +404,7 @@ TEST_F(AITTTest, Unsubscribe_TCP_P_Anytime) aitt.Connect(); subscribeHandle = aitt.Subscribe( testTopic, - [](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void {}, + [](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void {}, nullptr, AITT_TYPE_TCP); DBG("Subscribe handle: %p", reinterpret_cast(subscribeHandle)); aitt.Unsubscribe(subscribeHandle); @@ -423,7 +420,7 @@ TEST_F(AITTTest, Unsubscribe_SECURE_TCP_P_Anytime) aitt.Connect(); subscribeHandle = aitt.Subscribe( testTopic, - [](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void {}, + [](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void {}, nullptr, AITT_TYPE_TCP_SECURE); DBG("Subscribe handle: %p", reinterpret_cast(subscribeHandle)); aitt.Unsubscribe(subscribeHandle); @@ -449,9 +446,9 @@ TEST_F(AITTTest, Unsubscribe_in_Subscribe_MQTT_P_Anytime) aitt.Connect(); subscribeHandle = aitt.Subscribe( testTopic, - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void { + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTest *test = static_cast(cbdata); - DBG("Subscribe invoked: %s %zu", static_cast(msg), szmsg); + DBG("Subscribe invoked: %s %d", static_cast(msg), szmsg); static int cnt = 0; ++cnt; @@ -484,8 +481,8 @@ TEST_F(AITTTest, Subscribe_in_Subscribe_MQTT_P_Anytime) aitt.Connect(); subscribeHandle = aitt.Subscribe( testTopic, - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void { - DBG("Subscribe invoked: %s %zu", static_cast(msg), szmsg); + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { + DBG("Subscribe invoked: %s %d", static_cast(msg), szmsg); static int cnt = 0; ++cnt; @@ -494,12 +491,12 @@ TEST_F(AITTTest, Subscribe_in_Subscribe_MQTT_P_Anytime) aitt.Subscribe( "topic1InCallback", - [](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) {}, + [](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) {}, cbdata); aitt.Subscribe( "topic2InCallback", - [](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) {}, + [](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) {}, cbdata); DBG("Ready flag is toggled"); g_timeout_add( @@ -553,18 +550,18 @@ TEST_F(AITTTest, PublishSubscribe_Multiple_Protocols_P_Anytime) aitt.Connect(); aitt.Subscribe( testTopic, - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void { + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTest *test = static_cast(cbdata); - DBG("Subscribe invoked: %s %zu", static_cast(msg), szmsg); + DBG("Subscribe invoked: %s %d", static_cast(msg), szmsg); test->ToggleReady(); }, static_cast(this), AITT_TYPE_TCP); aitt.Subscribe( testTopic, - [&](aitt::MSG *handle, const void *msg, const size_t szmsg, void *cbdata) -> void { + [&](aitt::MSG *handle, const void *msg, const int szmsg, void *cbdata) -> void { AITTTest *test = static_cast(cbdata); - DBG("Subscribe invoked: %s %zu", static_cast(msg), szmsg); + DBG("Subscribe invoked: %s %d", static_cast(msg), szmsg); test->ToggleReady2(); }, static_cast(this), AITT_TYPE_MQTT); diff --git a/tests/MosquittoMQ_test.cc b/tests/MosquittoMQ_test.cc index 0491b8a..8e53c5e 100644 --- a/tests/MosquittoMQ_test.cc +++ b/tests/MosquittoMQ_test.cc @@ -35,20 +35,20 @@ TEST_F(MQTest, Subscribe_in_Subscribe_MQTT_P_Anytime) mq.Connect(LOCAL_IP, 1883, "", ""); mq.Subscribe( "MQ_TEST_TOPIC1", - [&](aitt::MSG *handle, const std::string &topic, const void *data, - const size_t datalen, void *user_data) { - DBG("Subscribe invoked: %s %zu", static_cast(data), datalen); + [&](aitt::MSG *handle, const std::string &topic, const void *data, const int datalen, + void *user_data) { + DBG("Subscribe invoked: %s %d", static_cast(data), datalen); mq.Subscribe( "topic1InCallback", [](aitt::MSG *handle, const std::string &topic, const void *msg, - const size_t szmsg, void *cbdata) {}, + const int szmsg, void *cbdata) {}, user_data); mq.Subscribe( "topic2InCallback", [](aitt::MSG *handle, const std::string &topic, const void *msg, - const size_t szmsg, void *cbdata) {}, + const int szmsg, void *cbdata) {}, user_data); g_timeout_add( 100, diff --git a/tests/RequestResponse_test.cc b/tests/RequestResponse_test.cc index 21bcd0f..bbcf983 100644 --- a/tests/RequestResponse_test.cc +++ b/tests/RequestResponse_test.cc @@ -27,12 +27,12 @@ using AITT = aitt::AITT; class AITTRRTest : public testing::Test, public AittTests { public: void PublishSyncInCallback(aitt::AITT *aitt, bool *reply1_ok, bool *reply2_ok, aitt::MSG *msg, - const void *data, const size_t datalen, void *cbdata) + const void *data, const int datalen, void *cbdata) { aitt->PublishWithReplySync( rr_topic.c_str(), message.c_str(), message.size(), AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE, false, - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { CheckReply(msg, data, datalen); *reply1_ok = true; }, @@ -45,7 +45,7 @@ class AITTRRTest : public testing::Test, public AittTests { } void CheckReplyCallback(bool toggle, bool *reply_ok, aitt::MSG *msg, const void *data, - const size_t datalen, void *cbdata) + const int datalen, void *cbdata) { CheckReply(msg, data, datalen); *reply_ok = true; @@ -57,7 +57,7 @@ class AITTRRTest : public testing::Test, public AittTests { void SetUp() override { Init(); } void TearDown() override { Deinit(); } - void CheckReply(aitt::MSG *msg, const void *data, const size_t datalen) + void CheckReply(aitt::MSG *msg, const void *data, const int datalen) { std::string received_data((const char *)data, datalen); EXPECT_EQ(msg->GetCorrelation(), correlation); @@ -65,7 +65,7 @@ class AITTRRTest : public testing::Test, public AittTests { EXPECT_EQ(msg->IsEndSequence(), true); } - void CheckSubscribe(aitt::MSG *msg, const void *data, const size_t datalen) + void CheckSubscribe(aitt::MSG *msg, const void *data, const int datalen) { std::string received_data((const char *)data, datalen); EXPECT_TRUE(msg->GetTopic() == rr_topic); @@ -84,7 +84,7 @@ class AITTRRTest : public testing::Test, public AittTests { aitt.Connect(); aitt.Subscribe(rr_topic.c_str(), - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { CheckSubscribe(msg, data, datalen); aitt.SendReply(msg, reply.c_str(), reply.size()); sub_ok = true; @@ -129,7 +129,7 @@ class AITTRRTest : public testing::Test, public AittTests { INFO("Connected"); sub_aitt.Subscribe(rr_topic.c_str(), - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { CheckSubscribe(msg, data, datalen); sub_aitt.SendReply(msg, reply.c_str(), reply.size()); sub_ok = true; @@ -176,7 +176,7 @@ TEST_F(AITTRRTest, RequestResponse_P_Anytime) aitt.Connect(); aitt.Subscribe(rr_topic.c_str(), - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { CheckSubscribe(msg, data, datalen); aitt.SendReply(msg, reply.c_str(), reply.size()); sub_ok = true; @@ -213,7 +213,7 @@ TEST_F(AITTRRTest, RequestResponse_asymmetry_Anytime) aitt.Connect(); aitt.Subscribe(rr_topic.c_str(), - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { CheckSubscribe(msg, data, datalen); aitt.SendReply(msg, reply1.c_str(), reply1.size(), false); @@ -226,7 +226,7 @@ TEST_F(AITTRRTest, RequestResponse_asymmetry_Anytime) aitt.PublishWithReply( rr_topic.c_str(), message.c_str(), message.size(), AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE, false, - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { std::string reply((const char *)data, datalen); EXPECT_EQ(msg->GetCorrelation(), correlation); @@ -281,7 +281,7 @@ TEST_F(AITTRRTest, RequestResponse_sync_P_Anytime) aitt.Connect(); aitt.Subscribe(rr_topic.c_str(), - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { CheckSubscribe(msg, data, datalen); aitt.SendReply(msg, reply.c_str(), reply.size()); sub_ok = true; @@ -341,7 +341,7 @@ TEST_F(AITTRRTest, RequestResponse_timeout_P_Anytime) int ret = aitt.PublishWithReplySync( rr_topic.c_str(), message.c_str(), message.size(), AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE, false, - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { FAIL() << "Should not be called"; }, nullptr, correlation, 1); @@ -361,7 +361,7 @@ TEST_F(AITTRRTest, RequestResponse_timeout_restart_P_Anytime) AITT sub_aitt(clientId + "sub", LOCAL_IP, AittOption(true, false)); sub_aitt.Connect(); sub_aitt.Subscribe(rr_topic.c_str(), - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { INFO("Subscribe Callback is called"); CheckSubscribe(msg, data, datalen); sub_aitt.SendReply(msg, reply.c_str(), reply.size(), false); @@ -374,7 +374,7 @@ TEST_F(AITTRRTest, RequestResponse_timeout_restart_P_Anytime) int ret = aitt.PublishWithReplySync( rr_topic.c_str(), message.c_str(), message.size(), AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE, false, - [&](aitt::MSG *msg, const void *data, const size_t datalen, void *cbdata) { + [&](aitt::MSG *msg, const void *data, const int datalen, void *cbdata) { INFO("Reply Callback is called"); static int invalid = 0; if (invalid) diff --git a/tests/aitt_c_manualtest.cc b/tests/aitt_c_manualtest.cc index d8b7c25..bc9932b 100644 --- a/tests/aitt_c_manualtest.cc +++ b/tests/aitt_c_manualtest.cc @@ -36,7 +36,7 @@ TEST(AITT_C_MANUAL, will_set_P) aitt_sub_h sub_handle = nullptr; ret = aitt_subscribe( handle, TEST_C_WILL_TOPIC, - [](aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data) { + [](aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data) { std::string received_data((const char *)msg, msg_len); EXPECT_STREQ(received_data.c_str(), TEST_C_MSG); EXPECT_STREQ(aitt_msg_get_topic(msg_handle), TEST_C_WILL_TOPIC); diff --git a/tests/aitt_c_test.cc b/tests/aitt_c_test.cc index 68e0cf9..5a43eff 100644 --- a/tests/aitt_c_test.cc +++ b/tests/aitt_c_test.cc @@ -191,7 +191,7 @@ TEST(AITT_C_INTERFACE, pub_sub_P_Anytime) aitt_sub_h sub_handle = nullptr; ret = aitt_subscribe( handle, TEST_C_TOPIC, - [](aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data) { + [](aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data) { GMainLoop *loop = static_cast(user_data); std::string received_data((const char *)msg, msg_len); EXPECT_STREQ(received_data.c_str(), TEST_C_MSG); @@ -269,12 +269,11 @@ TEST(AITT_C_INTERFACE, sub_N_Anytime) EXPECT_NE(ret, AITT_ERROR_NONE); ret = aitt_subscribe( - handle, TEST_C_TOPIC, [](aitt_msg_h, const void *, size_t, void *) {}, nullptr, - &sub_handle); + handle, TEST_C_TOPIC, [](aitt_msg_h, const void *, int, void *) {}, nullptr, &sub_handle); EXPECT_EQ(ret, AITT_ERROR_NOT_READY); ret = aitt_subscribe( - nullptr, TEST_C_TOPIC, [](aitt_msg_h, const void *, size_t, void *) {}, nullptr, + nullptr, TEST_C_TOPIC, [](aitt_msg_h, const void *, int, void *) {}, nullptr, &sub_handle); EXPECT_EQ(ret, AITT_ERROR_INVALID_PARAMETER); @@ -282,7 +281,7 @@ TEST(AITT_C_INTERFACE, sub_N_Anytime) ASSERT_EQ(ret, AITT_ERROR_NONE); ret = aitt_subscribe( - handle, nullptr, [](aitt_msg_h, const void *, size_t, void *) {}, nullptr, &sub_handle); + handle, nullptr, [](aitt_msg_h, const void *, int, void *) {}, nullptr, &sub_handle); EXPECT_EQ(ret, AITT_ERROR_INVALID_PARAMETER); ret = aitt_subscribe(handle, TEST_C_TOPIC, nullptr, nullptr, &sub_handle); @@ -316,7 +315,7 @@ TEST(AITT_C_INTERFACE, pub_with_reply_send_reply_P_Anytime) aitt_sub_h sub_handle = nullptr; ret = aitt_subscribe( handle, TEST_C_TOPIC, - [](aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data) { + [](aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data) { aitt_h handle = static_cast(user_data); std::string received_data((const char *)msg, msg_len); EXPECT_STREQ(received_data.c_str(), TEST_C_MSG); @@ -329,7 +328,7 @@ TEST(AITT_C_INTERFACE, pub_with_reply_send_reply_P_Anytime) ret = aitt_publish_with_reply( handle, TEST_C_TOPIC, TEST_C_MSG, strlen(TEST_C_MSG), AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE, test_correlation, - [](aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data) { + [](aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data) { GMainLoop *loop = static_cast(user_data); std::string received_data((const char *)msg, msg_len); EXPECT_STREQ(received_data.c_str(), reply_msg); @@ -366,18 +365,18 @@ TEST(AITT_C_INTERFACE, pub_with_reply_N_Anytime) ret = aitt_publish_with_reply( nullptr, TEST_C_TOPIC, TEST_C_MSG, strlen(TEST_C_MSG), AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE, test_correlation, - [](aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data) {}, nullptr); + [](aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data) {}, nullptr); EXPECT_EQ(ret, AITT_ERROR_INVALID_PARAMETER); ret = aitt_publish_with_reply( handle, nullptr, TEST_C_MSG, strlen(TEST_C_MSG), AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE, test_correlation, - [](aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data) {}, nullptr); + [](aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data) {}, nullptr); EXPECT_EQ(ret, AITT_ERROR_INVALID_PARAMETER); ret = aitt_publish_with_reply( handle, TEST_C_TOPIC, nullptr, 0, AITT_TYPE_MQTT, AITT_QOS_AT_MOST_ONCE, test_correlation, - [](aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data) {}, nullptr); + [](aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data) {}, nullptr); EXPECT_EQ(ret, AITT_ERROR_INVALID_PARAMETER); ret = aitt_publish_with_reply(handle, TEST_C_TOPIC, TEST_C_MSG, strlen(TEST_C_MSG), @@ -409,7 +408,7 @@ TEST(AITT_C_INTERFACE, sub_unsub_P_Anytime) static aitt_sub_h sub_handle = nullptr; ret = aitt_subscribe( handle, TEST_C_TOPIC, - [](aitt_msg_h msg_handle, const void *msg, size_t msg_len, void *user_data) { + [](aitt_msg_h msg_handle, const void *msg, int msg_len, void *user_data) { sub_call_count++; }, nullptr, &sub_handle); -- 2.7.4