File tree Expand file tree Collapse file tree 13 files changed +72
-33
lines changed
Expand file tree Collapse file tree 13 files changed +72
-33
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,6 @@ set_target_properties(edgesec PROPERTIES
6767
6868if (USE_CAPTURE_SERVICE)
6969 add_executable (edgesec-recap edgesec-recap.c)
70- target_link_libraries (edgesec-recap PRIVATE capture_service protobuf_middleware packet_queue packet_decoder sqlite_header os log SQLite::SQLite3 eloop::eloop)
70+ target_link_libraries (edgesec-recap PRIVATE capture_service protobuf_middleware packet_queue packet_decoder sqlite_header attributes os log SQLite::SQLite3 eloop::eloop)
7171 target_include_directories (edgesec-recap PRIVATE ${PROJECT_BINARY_DIR} )
7272endif ()
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ target_link_libraries(dns_decoder PUBLIC PCAP::pcap SQLite::SQLite3 PRIVATE log
1212
1313# packet_decoder.h has an #include <pcap.h>, so need to make it PUBLIC include
1414add_library (packet_decoder packet_decoder.c)
15- target_link_libraries (packet_decoder PUBLIC PCAP::pcap LibUTHash::LibUTHash PRIVATE mdns_decoder dns_decoder hash net log os hashmap)
15+ target_link_libraries (packet_decoder PUBLIC PCAP::pcap LibUTHash::LibUTHash attributes PRIVATE mdns_decoder dns_decoder hash net log os hashmap)
1616
1717add_library (packet_queue packet_queue.c)
1818target_link_libraries (packet_queue PUBLIC packet_decoder eloop::list PRIVATE log os)
Original file line number Diff line number Diff line change 1616
1717#include <utarray.h>
1818#include "../../../utils/allocs.h"
19+ #include "../../../utils/attributes.h"
1920#include "../../../utils/net.h"
2021#include "../../../utils/os.h"
2122
Original file line number Diff line number Diff line change 3030#include "capture/middlewares/header_middleware/packet_queue.h"
3131#include "capture/middlewares/header_middleware/sqlite_header.h"
3232#include "capture/middlewares/protobuf_middleware/protobuf_middleware.h"
33+ #include "utils/attributes.h"
3334#include "utils/os.h"
3435#include "utils/sqliteu.h"
3536#include "version.h"
Original file line number Diff line number Diff line change @@ -2,19 +2,25 @@ include_directories (
22 "${PROJECT_SOURCE_DIR} /src"
33)
44
5+ add_library (common INTERFACE )
6+ set_target_properties (common PROPERTIES PUBLIC_HEADER "common.h" )
7+ target_link_libraries (common INTERFACE attributes allocs log )
8+
59add_library (md5_internal md5_internal.c)
610target_link_libraries (md5_internal PRIVATE log os)
711
812add_library (md5 md5.c)
913target_link_libraries (md5 PRIVATE md5_internal os)
1014
1115add_library (wpabuf wpabuf.c)
12- target_link_libraries (wpabuf PRIVATE log os)
16+ target_link_libraries (wpabuf PUBLIC common PRIVATE log os)
1317# wpabuf.h has BSD functions like be16toh, see https://linux.die.net/man/3/be16toh
1418target_compile_definitions (wpabuf PUBLIC _DEFAULT_SOURCE _BSD_SOURCE)
1519
1620add_library (radius radius.c)
17- target_link_libraries (radius PRIVATE wpabuf md5 md5_internal log os)
21+ target_link_libraries (radius
22+ PUBLIC common attributes
23+ PRIVATE wpabuf md5 md5_internal log os)
1824
1925add_library (radius_server radius_server.c)
2026target_link_libraries (radius_server PUBLIC os eloop::eloop PRIVATE radius wpabuf log net)
Original file line number Diff line number Diff line change 1515
1616#include <stddef.h>
1717
18+ #include "../utils/attributes.h"
1819#include "utils/allocs.h"
1920#include "utils/log.h"
2021
Original file line number Diff line number Diff line change 1616
1717#include "common.h"
1818
19+ #include "../utils/attributes.h"
1920#include "utils/os.h"
2021
2122/* RFC 2865 - RADIUS */
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ set_target_properties(log PROPERTIES C_EXTENSIONS ON POSITION_INDEPENDENT_CODE O
44
55add_library (allocs allocs.c)
66
7+ add_library (attributes INTERFACE ) # #define's for compiler attributes
8+ set_target_properties (attributes PROPERTIES PUBLIC_HEADER "attributes.h" )
9+
710if (USE_CRYPTO_SERVICE)
811 add_library (cryptou cryptou.c)
912 target_link_libraries (cryptou PRIVATE base64 os log OpenSSL::Crypto)
Original file line number Diff line number Diff line change 1+ /**
2+ * @file
3+ * @author Alois Klink <[email protected] > 4+ * @date 2023
5+ * @copyright
6+ * SPDX-FileCopyrightText: © 2023 NQMCyber Ltd and edgesec contributors
7+ * SPDX-License-Identifier: Expat
8+ * @brief File containing macros for compiler attributes, if they are supported.
9+ *
10+ * In the future, once we support C23, we can remove this header and just
11+ * use C23 attributes.
12+ */
13+ #ifndef ATTRIBUTES_H
14+ #define ATTRIBUTES_H
15+
16+ #ifndef __maybe_unused
17+ #if defined __has_attribute
18+ #if __has_attribute (unused )
19+ /**
20+ * If used before a variable, tells the compiler that variable can be unused.
21+ * (e.g. does the same thing as casting to `(void)`, or `[[maybe_unused]]` in
22+ * C23).
23+ *
24+ * @see https://clang.llvm.org/docs/AttributeReference.html#maybe-unused-unused
25+ */
26+ #define __maybe_unused __attribute__((unused))
27+ #else
28+ #define __maybe_unused
29+ #endif /* __has_attribute(unused) */
30+ #else
31+ #define __maybe_unused
32+ #endif /* defined __has_attribute */
33+ #endif /* __maybe_unused */
34+
35+ #ifdef __GNUC__
36+ #define STRUCT_PACKED __attribute__((packed))
37+ #else
38+ #define STRUCT_PACKED
39+ #endif
40+
41+ #endif /* ATTRIBUTES_H */
Original file line number Diff line number Diff line change 3232
3333#define OS_HOST_NAME_MAX 64
3434
35- #ifdef __GNUC__
36- #define STRUCT_PACKED __attribute__((packed))
37- #else
38- #define STRUCT_PACKED
39- #endif
40-
4135#ifndef BIT
4236#define BIT (x ) (1U << (x))
4337#endif
You can’t perform that action at this time.
0 commit comments