Skip to content

Commit

Permalink
Move mqtt_websockets under aclk/ (netdata#16804)
Browse files Browse the repository at this point in the history
* Move mqtt_websockets under aclk/

* Use relative paths for includes from mqtt_websockets

...in order to reduce the number of header
search paths that we use when building the
agent. Ideally, we'd make each component a
standalone library target from CMake's
perspective but more work needs to be done
before we are able to do this.

* Remove unused files.

* Make licensing information consistent across all files.

* Flatten the hierarchy of source files.
  • Loading branch information
vkalintiris authored Jan 18, 2024
1 parent 83d1250 commit dedc5be
Show file tree
Hide file tree
Showing 56 changed files with 80 additions and 3,000 deletions.
46 changes: 22 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1295,23 +1295,23 @@ elseif(FREEBSD)
endif()

set(MQTT_WEBSOCKETS_FILES
mqtt_websockets/src/mqtt_wss_client.c
mqtt_websockets/src/include/mqtt_wss_client.h
mqtt_websockets/src/mqtt_wss_log.c
mqtt_websockets/src/include/mqtt_wss_log.h
mqtt_websockets/src/ws_client.c
mqtt_websockets/src/include/ws_client.h
mqtt_websockets/src/mqtt_ng.c
mqtt_websockets/src/include/mqtt_ng.h
mqtt_websockets/src/common_public.c
mqtt_websockets/src/include/common_public.h
mqtt_websockets/src/include/common_internal.h
mqtt_websockets/c-rbuf/src/ringbuffer.c
mqtt_websockets/c-rbuf/include/ringbuffer.h
mqtt_websockets/c-rbuf/src/ringbuffer_internal.h
mqtt_websockets/c_rhash/src/c_rhash.c
mqtt_websockets/c_rhash/include/c_rhash.h
mqtt_websockets/c_rhash/src/c_rhash_internal.h
aclk/mqtt_websockets/mqtt_wss_client.c
aclk/mqtt_websockets/mqtt_wss_client.h
aclk/mqtt_websockets/mqtt_wss_log.c
aclk/mqtt_websockets/mqtt_wss_log.h
aclk/mqtt_websockets/ws_client.c
aclk/mqtt_websockets/ws_client.h
aclk/mqtt_websockets/mqtt_ng.c
aclk/mqtt_websockets/mqtt_ng.h
aclk/mqtt_websockets/common_public.c
aclk/mqtt_websockets/common_public.h
aclk/mqtt_websockets/common_internal.h
aclk/mqtt_websockets/c-rbuf/cringbuffer.c
aclk/mqtt_websockets/c-rbuf/cringbuffer.h
aclk/mqtt_websockets/c-rbuf/cringbuffer_internal.h
aclk/mqtt_websockets/c_rhash/c_rhash.c
aclk/mqtt_websockets/c_rhash/c_rhash.h
aclk/mqtt_websockets/c_rhash/c_rhash_internal.h
)

set(ACLK_PROTO_DEFS
Expand Down Expand Up @@ -1637,11 +1637,11 @@ if (ENABLE_H2O OR ENABLE_ACLK)
endif()

if(ENABLE_MQTTWEBSOCKETS)
include_directories(BEFORE
${CMAKE_SOURCE_DIR}/mqtt_websockets/src/include
${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include
${CMAKE_SOURCE_DIR}/mqtt_websockets/c_rhash/include
)
# include_directories(BEFORE
# ${CMAKE_SOURCE_DIR}/aclk/mqtt_websockets/src/include
# ${CMAKE_SOURCE_DIR}/aclk/mqtt_websockets/c-rbuf/include
# ${CMAKE_SOURCE_DIR}/aclk/mqtt_websockets/c_rhash/include
# )

add_library(mqttwebsockets STATIC ${MQTT_WEBSOCKETS_FILES})

Expand Down Expand Up @@ -1995,8 +1995,6 @@ target_compile_definitions(netdata PRIVATE
target_include_directories(netdata PRIVATE
"$<$<BOOL:${ENABLE_PROTOBUF}>:${PROTOBUF_INCLUDE_DIRS}>"
"$<$<BOOL:${ENABLE_ACLK}>:${CMAKE_SOURCE_DIR}/aclk/aclk-schemas>"
"$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:${CMAKE_SOURCE_DIR}/mqtt_websockets/src/include>"
"$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include>"
"$<$<BOOL:${ENABLE_ML}>:${CMAKE_SOURCE_DIR}/ml/dlib>"
"$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGOC_INCLUDE_DIRS}>"
"$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${SNAPPY_INCLUDE_DIRS}>"
Expand Down
2 changes: 1 addition & 1 deletion aclk/aclk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#ifdef ENABLE_ACLK
#include "aclk_stats.h"
#include "mqtt_wss_client.h"
#include "mqtt_websockets/mqtt_wss_client.h"
#include "aclk_otp.h"
#include "aclk_tx_msgs.h"
#include "aclk_query.h"
Expand Down
2 changes: 1 addition & 1 deletion aclk/aclk_otp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "daemon/common.h"

#include "mqtt_websockets/c-rbuf/include/ringbuffer.h"
#include "mqtt_websockets/c-rbuf/cringbuffer.h"

static int aclk_https_request(https_req_t *request, https_req_response_t *response) {
int rc;
Expand Down
2 changes: 1 addition & 1 deletion aclk/aclk_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "libnetdata/libnetdata.h"

#include "mqtt_wss_client.h"
#include "mqtt_websockets/mqtt_wss_client.h"

#include "aclk_query_queue.h"

Expand Down
2 changes: 1 addition & 1 deletion aclk/aclk_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "daemon/common.h"
#include "libnetdata/libnetdata.h"
#include "aclk_query_queue.h"
#include "mqtt_wss_client.h"
#include "mqtt_websockets/mqtt_wss_client.h"

extern netdata_mutex_t aclk_stats_mutex;

Expand Down
2 changes: 1 addition & 1 deletion aclk/aclk_tx_msgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <json-c/json.h>
#include "libnetdata/libnetdata.h"
#include "daemon/common.h"
#include "mqtt_wss_client.h"
#include "mqtt_websockets/mqtt_wss_client.h"
#include "schema-wrappers/schema_wrappers.h"
#include "aclk_util.h"

Expand Down
2 changes: 1 addition & 1 deletion aclk/aclk_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "libnetdata/libnetdata.h"

#ifdef ENABLE_ACLK
#include "mqtt_wss_client.h"
#include "mqtt_websockets/mqtt_wss_client.h"

#define CLOUD_EC_MALFORMED_NODE_ID 1
#define CLOUD_EMSG_MALFORMED_NODE_ID "URL requests node_id but there is not enough chars following (for it to be valid uuid)."
Expand Down
4 changes: 2 additions & 2 deletions aclk/https_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "libnetdata/libnetdata.h"

#include "mqtt_websockets/c-rbuf/include/ringbuffer.h"
#include "mqtt_websockets/c_rhash/include/c_rhash.h"
#include "mqtt_websockets/c-rbuf/cringbuffer.h"
#include "mqtt_websockets/c_rhash/c_rhash.h"

typedef enum http_req_type {
HTTP_REQ_GET = 0,
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions aclk/mqtt_websockets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# mqtt_websockets

Library to connect MQTT client over Websockets Secure (WSS).

## License

The Project is released under GPL v3 license. See [License](LICENSE)
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/*
*
* Copyright: SPDX-License-Identifier: LGPL-3.0-only
*
* Author: Timotej Šiškovič <timotejs@gmail.com>
*
*/

#include "ringbuffer.h"
#include "ringbuffer_internal.h"
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include "cringbuffer.h"
#include "cringbuffer_internal.h"

#include <stdlib.h>
#include <assert.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/*
*
* Copyright: SPDX-License-Identifier: LGPL-3.0-only
*
* Author: Timotej Šiškovič <timotejs@gmail.com>
*
*/
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#ifndef RINGBUFFER_H
#define RINGBUFFER_H
#ifndef CRINGBUFFER_H
#define CRINGBUFFER_H

#include <stddef.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/*
*
* Copyright: SPDX-License-Identifier: LGPL-3.0-only
*
* Author: Timotej Šiškovič <timotejs@gmail.com>
*
*/
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#ifndef RINGBUFFER_INTERNAL_H
#define RINGBUFFER_INTERNAL_H
#ifndef CRINGBUFFER_INTERNAL_H
#define CRINGBUFFER_INTERNAL_H

struct rbuf_t {
char *data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
/*
*
* Copyright: SPDX-License-Identifier: LGPL-3.0-only
*
* Author: Timotej Šiškovič <timotejs@gmail.com>
*
*/
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include "ringbuffer.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include "c_rhash_internal.h"

#include <stdlib.h>
Expand Down Expand Up @@ -259,4 +261,4 @@ void c_rhash_destroy(c_rhash hash) {
c_rhash_destroy_bin(hash->bins[i]);
}
c_rfree(hash);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include <sys/types.h>
#include <stdint.h>
#include <stddef.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include "c_rhash.h"

struct bin_item {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include <stdio.h>
#include <string.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
// SPDX-License-Identifier: GPL-3.0-only
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program.
// If not, see <https://www.gnu.org/licenses/>.

#ifndef COMMON_INTERNAL_H
#define COMMON_INTERNAL_H
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include "common_public.h"

// this dummy exists to have a special pointer with special meaning
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
// SPDX-License-Identifier: GPL-3.0-only
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program.
// If not, see <https://www.gnu.org/licenses/>.

#ifndef MQTT_WSS_ENDIAN_COMPAT_H
#define MQTT_WSS_ENDIAN_COMPAT_H
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#ifndef MQTT_CONSTANTS_H
#define MQTT_CONSTANTS_H

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
Expand All @@ -8,7 +10,7 @@
#include <pthread.h>
#include <inttypes.h>

#include "c_rhash.h"
#include "c_rhash/c_rhash.h"

#include "common_internal.h"
#include "mqtt_constants.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include <stdint.h>
#include <sys/types.h>
#include <time.h>

#include "ringbuffer.h"
#include "c-rbuf/cringbuffer.h"
#include "common_public.h"

#define MQTT_NG_MSGGEN_OK 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
// Copyright (C) 2020 Timotej Šiškovič
// SPDX-License-Identifier: GPL-3.0-only
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program.
// If not, see <https://www.gnu.org/licenses/>.
// Copyright (C) 2020 Timotej Šiškovič

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
// Copyright (C) 2020 Timotej Šiškovič
// SPDX-License-Identifier: GPL-3.0-only
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program.
// If not, see <https://www.gnu.org/licenses/>.
// Copyright (C) 2020 Timotej Šiškovič

#ifndef MQTT_WSS_CLIENT_H
#define MQTT_WSS_CLIENT_H
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "mqtt_wss_log.h"
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>

#include "mqtt_wss_log.h"
#include "common_internal.h"

struct mqtt_wss_log_ctx {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright: SPDX-License-Identifier: GPL-3.0-only

#ifndef MQTT_WSS_LOG_H
#define MQTT_WSS_LOG_H

Expand Down
12 changes: 1 addition & 11 deletions mqtt_websockets/src/test.c → aclk/mqtt_websockets/test.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
// Copyright (C) 2020 Timotej Šiškovič
// SPDX-License-Identifier: GPL-3.0-only
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program.
// If not, see <https://www.gnu.org/licenses/>.
// Copyright (C) 2020 Timotej Šiškovič

#include <unistd.h>
#include <stdio.h>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
// Copyright (C) 2020 Timotej Šiškovič
// SPDX-License-Identifier: GPL-3.0-only
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program.
// If not, see <https://www.gnu.org/licenses/>.
// Copyright (C) 2020 Timotej Šiškovič

#ifndef WS_CLIENT_H
#define WS_CLIENT_H

#include "ringbuffer.h"
#include "c-rbuf/cringbuffer.h"
#include "mqtt_wss_log.h"

#include <stdint.h>
Expand Down
Loading

0 comments on commit dedc5be

Please sign in to comment.