Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ if(ENABLE_NETWORKED_STANDBY_MODE)
add_compile_definitions(NETWORKED_STANDBY_MODE_ENABLED)
endif()

if(FDC_ENABLED)
add_compile_definitions(FDC_ENABLED)
endif()
#if(FDC_ENABLED)
add_compile_definitions(PUBLIC FDC_ENABLED)
#endif()

if(IP_ENABLED)
add_compile_definitions(CTRLM_NETWORK_IP CTRLM_IP_HAL_LOG_ENABLED)
Expand Down
82 changes: 82 additions & 0 deletions src/auth/ctrlm_hal_certificate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* If not stated otherwise in this file or this component's LICENSE file
* the following copyright and licenses apply:
*
* Copyright 2023 RDK Management

Check failure on line 5 in src/auth/ctrlm_hal_certificate.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'src/auth/ctrlm_hal_certificate.h' (Match: rdkcentral/rdkservices/1, 12 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/GRT_v1.tar.gz, file: RemoteControl/test/Module.h)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef __CTRLM_HAL_CERTIFICATE_H__
#define __CTRLM_HAL_CERTIFICATE_H__

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <openssl/ssl.h>

#define PASSPHRASE_LEN_MAX (32)

typedef enum {
CTRLM_VOICE_CERT_TYPE_NONE = 0,
CTRLM_VOICE_CERT_TYPE_P12 = 1,
CTRLM_VOICE_CERT_TYPE_PEM = 2,
CTRLM_VOICE_CERT_TYPE_X509 = 3,
CTRLM_VOICE_CERT_TYPE_INVALID = 4
} ctrlm_voice_cert_type_t;

typedef struct {
const char *certificate;
const char *passphrase;
} ctrlm_voice_cert_p12_t;

typedef struct {
const char *filename_cert;
const char *filename_pkey;
const char *filename_chain;
const char *passphrase;
} ctrlm_voice_cert_pem_t;

typedef struct {
X509 * cert_x509;
EVP_PKEY * cert_pkey;
STACK_OF(X509) *cert_chain;
} ctrlm_voice_cert_x509_t;

typedef struct {
ctrlm_voice_cert_type_t type;
union {
ctrlm_voice_cert_p12_t p12;
ctrlm_voice_cert_pem_t pem;
ctrlm_voice_cert_x509_t x509;
} cert;
} ctrlm_voice_cert_t;

class ctrlm_hal_certificate_t {
public:
ctrlm_hal_certificate_t();
virtual ~ctrlm_hal_certificate_t();

virtual bool device_cert_get(ctrlm_voice_cert_t &device_cert, bool &ocsp_verify_stapling, bool &ocsp_verify_ca);

private:
virtual bool device_cert_p12_set(const char *certificate, const char *passphrase);

ctrlm_voice_cert_t device_cert;
bool ocsp_verify_stapling;
bool ocsp_verify_ca;
};

ctrlm_hal_certificate_t *ctrlm_hal_certificate_get();

#endif
7 changes: 6 additions & 1 deletion src/ble/ctrlm_ble_rcu_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "ctrlm_ble_rcu_interface.h"
#include "ctrlm_ble_utils.h"
#include "ctrlm_voice_obj.h"

#include <unistd.h>

#define CTRLM_BLE_KEY_MSG_QUEUE_MSG_MAX (10)
#define CTRLM_BLE_KEY_MSG_QUEUE_MSG_SIZE_MAX (sizeof(ctrlm_ble_key_queue_device_changed_msg_t))
Expand Down Expand Up @@ -1516,6 +1516,7 @@ static int OpenKeyInputDevice(uint64_t ieee_address)
return input_fd;
}
}
XLOGD_INFO("closing fd <%d>", input_fd);
close(input_fd);
if (NULL != evdev) {
libevdev_free(evdev);
Expand Down Expand Up @@ -1599,6 +1600,7 @@ void *KeyMonitorThread(void *data)
sem_post(&metadata->m_keyThreadSem);

XLOGD_INFO("Enter main loop for new key monitor thread");
XLOGD_INFO("TID <%d>", (int)gettid());
do {
// Needs to be reinitialized before each call to select() because select() will modify these variables
FD_ZERO(&rfds);
Expand Down Expand Up @@ -1644,6 +1646,7 @@ void *KeyMonitorThread(void *data)

if (rcuKeypressFds.end() != rcuKeypressFds.find(device_changed_msg->address)) {
if (rcuKeypressFds[device_changed_msg->address] >= 0) {
XLOGD_INFO("closing fd <%d>", rcuKeypressFds[device_changed_msg->address]);
close(rcuKeypressFds[device_changed_msg->address]);
}
rcuKeypressFds.erase(device_changed_msg->address);
Expand All @@ -1657,6 +1660,7 @@ void *KeyMonitorThread(void *data)
if (rcu.second >= 0) {
XLOGD_INFO("Closing key input device for RCU <%s> so key monitor thread can reopen...",
rcu.first.toString().c_str());
XLOGD_INFO("closing fd <%d>", rcu.second);
close(rcu.second);
rcu.second = -1;
}
Expand All @@ -1675,6 +1679,7 @@ void *KeyMonitorThread(void *data)

for (auto &rcu : rcuKeypressFds) {
if (rcu.second >= 0) {
XLOGD_INFO("closing fd <%d>", rcu.second);
close(rcu.second);
rcu.second = -1;
}
Expand Down
4 changes: 4 additions & 0 deletions src/ble/hal/blercu/bleservices/gatt/gatt_audiopipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ GattAudioPipe::~GattAudioPipe()
*m_isAlive = false;

// close any fds that we may still have open
XLOGD_INFO("closing fd <%d>", m_outputPipeRdFd);
if ((m_outputPipeRdFd >= 0) && (::close(m_outputPipeRdFd) != 0)) {
int errsv = errno;
XLOGD_ERROR("failed to close output read pipe fd: error = <%d>, <%s>", errsv, strerror(errsv));
}

XLOGD_INFO("closing fd <%d>", m_outputPipeWrFd);
if ((m_outputPipeWrFd >= 0) && (::close(m_outputPipeWrFd) != 0)) {
int errsv = errno;
XLOGD_ERROR("failed to close output write pipe fd: error = <%d>, <%s>", errsv, strerror(errsv));
Expand Down Expand Up @@ -294,6 +296,7 @@ int GattAudioPipe::takeOutputReadFd()
}

// now close our internal copy
XLOGD_INFO("closing fd <%d>", m_outputPipeRdFd);
if (::close(m_outputPipeRdFd) != 0) {
int errsv = errno;
XLOGD_ERROR("failed to close internal copy of read end of output pipe: error = <%d>, <%s>",
Expand Down Expand Up @@ -435,6 +438,7 @@ void GattAudioPipe::onOutputPipeException(int pipeFd)
XLOGD_DEBUG("detected close on the client output pipe");

// close the output pipe
XLOGD_INFO("closing fd <%d>", m_outputPipeWrFd);
if ((m_outputPipeWrFd >= 0) && (::close(m_outputPipeWrFd) != 0)) {
int errsv = errno;
XLOGD_ERROR("failed to close output pipe: error = <%d>, <%s>", errsv, strerror(errsv));
Expand Down
2 changes: 2 additions & 0 deletions src/ble/hal/blercu/bluez/blegattcharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ void BleGattCharacteristicBluez::enablePipeNotifications(const Slot<const std::v
}

if (mtu < 23) {
XLOGD_INFO("closing fd <%d>", pipeFd);
close(pipeFd);

XLOGD_ERROR("invalid MTU size on the notify pipe (%hd bytes)", mtu);
Expand All @@ -589,6 +590,7 @@ void BleGattCharacteristicBluez::enablePipeNotifications(const Slot<const std::v
m_notifyPipe = make_shared<BleGattNotifyPipe>(pipeFd, mtu, m_uuid);

//BleGattNotifyPipe dups the pipe, so close the original here.
XLOGD_INFO("closing fd <%d>", pipeFd);
close(pipeFd);

if (!m_notifyPipe || !m_notifyPipe->isValid()) {
Expand Down
7 changes: 6 additions & 1 deletion src/ble/hal/blercu/bluez/blegattnotifypipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,15 @@ void BleGattNotifyPipe::shutdown()
ThreadJoin(&m_notifyThread, 2);
}
if (FD_SIGNAL(m_exitEventFds) > -1) {
XLOGD_INFO("closing fd <%d>", FD_SIGNAL(m_exitEventFds));
close(FD_SIGNAL(m_exitEventFds));
}
if (FD_RECV(m_exitEventFds) > -1) {
XLOGD_INFO("closing fd <%d>", FD_RECV(m_exitEventFds));
close(FD_RECV(m_exitEventFds));
}

XLOGD_INFO("closing fd <%d>", m_pipeFd);
if ((m_pipeFd >= 0) && (::close(m_pipeFd) != 0)) {
int errsv = errno;
XLOGD_ERROR("failed to close notification pipe fd: error = <%d>, <%s>", errsv, strerror(errsv));
Expand Down Expand Up @@ -276,7 +279,8 @@ bool BleGattNotifyPipe::onActivated()
// this will stop the recording,
XLOGD_INFO("remote end of notification pipe closed for %s", m_uuid.toString().c_str());

if (::close(m_pipeFd) != 0) {
XLOGD_INFO("closing fd <%d>", m_pipeFd);
if (::close(m_pipeFd) != 0) {
int errsv = errno;
XLOGD_ERROR("failed to close pipe fd: error = <%d>, <%s>", errsv, strerror(errsv));
}
Expand Down Expand Up @@ -310,6 +314,7 @@ void *NotifyThread(void *data)

XLOGD_INFO("Enter main loop for bluez notification pipe (%d) for %s",
notifyPipe->m_pipeFd, notifyPipe->m_uuid.toString().c_str());
XLOGD_INFO("TID <%d>", (int)gettid());
do {
// Needs to be reinitialized before each call to select() because select() will modify these variables
FD_ZERO(&rfds);
Expand Down
4 changes: 4 additions & 0 deletions src/ble/hal/utils/filedescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ FileDescriptor::FileDescriptor(const FileDescriptor &other)

FileDescriptor &FileDescriptor::operator=(FileDescriptor &&other)
{

XLOGD_INFO("closing fd <%d>", m_fd);
if ((m_fd >= 0) && (::close(m_fd) != 0)) {
int errsv = errno;
XLOGD_ERROR("failed to close file descriptor: error = <%d>, <%s>", errsv, strerror(errsv));
Expand All @@ -99,6 +101,7 @@ FileDescriptor &FileDescriptor::operator=(FileDescriptor &&other)

FileDescriptor &FileDescriptor::operator=(const FileDescriptor &other)
{
XLOGD_INFO("closing fd <%d>", m_fd);
if ((m_fd >= 0) && (::close(m_fd) != 0)) {
int errsv = errno;
XLOGD_ERROR("failed to close file descriptor: error = <%d>, <%s>", errsv, strerror(errsv));
Expand Down Expand Up @@ -134,6 +137,7 @@ int FileDescriptor::fd() const

void FileDescriptor::reset()
{
XLOGD_INFO("closing fd <%d>", m_fd);
if ((m_fd >= 0) && (::close(m_fd) != 0)) {
int errsv = errno;
XLOGD_ERROR("failed to close file descriptor: error = <%d>, <%s>", errsv, strerror(errsv));
Expand Down
2 changes: 2 additions & 0 deletions src/ble/hal/utils/fwimagefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ FwImageFile::FwImageFile(const string &filePath)
// check the file header / contents
m_valid = checkFile();
if (!m_valid) {
XLOGD_INFO("closing fd <%d>", m_fd);
close(m_fd);
m_fd = -1;
}
}

FwImageFile::~FwImageFile()
{
XLOGD_INFO("closing fd <%d>", m_fd));
if ((m_fd >= 0) && (::close(m_fd) != 0)) {
int errsv = errno;
XLOGD_ERROR("failed to close file descriptor: error = <%d>, <%s>", errsv, strerror(errsv));
Expand Down
7 changes: 6 additions & 1 deletion src/ble/hal/utils/hcisocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// #include "linux/containerhelpers.h"

#include "ctrlm_log_ble.h"

#include <unistd.h>


using namespace std;
Expand Down Expand Up @@ -434,6 +434,7 @@ HciSocketImpl::HciSocketImpl(uint hciDeviceId, int netNsFd)

// setup the hci socket
if (!setSocketFilter(sockFd) || !bindSocket(sockFd, hciDeviceId)) {
XLOGD_INFO("closing <%d>", sockFd);
close(sockFd);
return;
}
Expand Down Expand Up @@ -462,14 +463,17 @@ HciSocketImpl::~HciSocketImpl()
ctrlm_utils_thread_join(&m_socketThread, 2);
}
if (FD_SIGNAL(m_exitEventFds) > -1) {
XLOGD_INFO("closing <%d>", FD_SIGNAL(m_exitEventFds));
close(FD_SIGNAL(m_exitEventFds));
}
if (FD_RECV(m_exitEventFds) > -1) {
XLOGD_INFO("closing <%d>", FD_RECV(m_exitEventFds));
close(FD_RECV(m_exitEventFds));
}

*m_isAlive = false;

XLOGD_INFO("closing fd <%d>", m_hciSocket);
if ((m_hciSocket >= 0) && (::close(m_hciSocket) != 0)) {
int errsv = errno;
XLOGD_WARN("failed to close hci socket %d (%s)", errsv, strerror(errsv));
Expand Down Expand Up @@ -1058,6 +1062,7 @@ void *SocketThread(void *data)
sem_post(&socketImpl->m_socketThreadSem);

XLOGD_INFO("Enter main loop for HCI socket thread");
XLOGD_INFO("TID <%d>", (int)gettid());
do {
if (FD_RECV(socketImpl->m_exitEventFds) < 0 || socketImpl->m_hciSocket < 0) {
XLOGD_ERROR("one of the fds is invalid, exiting thread");
Expand Down
5 changes: 5 additions & 0 deletions src/ctrlm_ir_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ctrlm_config_types.h"
#include "ctrlm_config_default.h"
#include "ctrlm_network.h"
#include "unistd.h"

#include <fcntl.h>

Expand Down Expand Up @@ -348,6 +349,7 @@ static int ctrlm_ir_open_key_input_device(vector<string> names) {
}
}
}
XLOGD_INFO("closing fd <%d>", input_fd);
close(input_fd);
if (NULL != evdev) {
libevdev_free(evdev);
Expand Down Expand Up @@ -376,6 +378,7 @@ static gboolean ctrlm_ir_retry_input_open(gpointer user_data) {

void* ctrlm_ir_key_monitor_thread(void *data) {
XLOGD_INFO("Enter...");
XLOGD_INFO("TID <%d>", (int)gettid());

ctrlm_ir_controller_t *ir_controller = (ctrlm_ir_controller_t *)data;

Expand Down Expand Up @@ -468,6 +471,7 @@ void* ctrlm_ir_key_monitor_thread(void *data) {
XLOGD_ERROR("error = <%d>, <%s>, closing and reopening device...", errsv, strerror(errsv));
input_device_retry_cnt = 0;
if (input_device_fd >= 0) {
XLOGD_INFO("closing fd <%d>", input_device_fd);
close(input_device_fd);
input_device_fd = -1;
}
Expand Down Expand Up @@ -521,6 +525,7 @@ void* ctrlm_ir_key_monitor_thread(void *data) {
ctrlm_timeout_destroy(&g_retry_input_open_timer_tag);

if (input_device_fd >= 0) {
XLOGD_INFO("closing fd <%d>", input_device_fd);
close(input_device_fd);
}
return NULL;
Expand Down
Loading
Loading