Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use netlink instead of Wireless Extensions #1879

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
libimlib2-dev \
libircclient-dev \
libiw-dev \
libnl-3-dev\
libnl-genl-3-dev\
libnl-route-3-dev\
liblua5.3-dev \
libmicrohttpd-dev \
libmysqlclient-dev \
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
libimlib2-dev \
libircclient-dev \
libiw-dev \
libnl-3-dev\
libnl-genl-3-dev\
libnl-route-3-dev\
liblua5.3-dev \
libmicrohttpd-dev \
libmysqlclient-dev \
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish-appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
libimlib2-dev \
libircclient-dev \
libiw-dev \
libnl-3-dev\
libnl-genl-3-dev\
libnl-route-3-dev\
liblua5.3-dev \
libmicrohttpd-dev \
libmysqlclient-dev \
Expand Down
15 changes: 15 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@
add_subdirectory(Vc)

add_subdirectory(toluapp)

if(BUILD_WLAN AND OS_LINUX)
set(linux_net_libs_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/linux")

# Sourced from linux kernel
# SHA: 18daea77cca626f590fb140fc11e3a43c5d41354
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/
# Only added structures and data that's used by conky to avoid cloning entire kernel

set(conky_includes ${conky_includes} ${linux_net_libs_INCLUDE_PATH})
endif(BUILD_WLAN AND OS_LINUX)

# Reexport includes and libs
set(conky_includes ${conky_includes} PARENT_SCOPE)
set(conky_libs ${conky_libs} PARENT_SCOPE)
4 changes: 4 additions & 0 deletions 3rdparty/linux/linux/ieee80211.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef __CONKY_LINUX_IEEE80211_H__
#define __CONKY_LINUX_IEEE80211_H__

#endif /* __CONKY_LINUX_IEEE80211_H__ */
3,352 changes: 3,352 additions & 0 deletions 3rdparty/linux/uapi/linux/nl80211.h

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ RUN apt-get update \
libimlib2-dev \
libircclient-dev \
libiw-dev \
libnl-3-dev\
libnl-genl-3-dev\
libnl-route-3-dev\
libjsoncpp-dev \
liblua5.3-dev \
libmicrohttpd-dev \
Expand Down
25 changes: 12 additions & 13 deletions cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,20 @@ if(BUILD_MYSQL)
endif(BUILD_MYSQL)

if(BUILD_WLAN AND OS_LINUX)
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_include_files(iwlib.h IWLIB_H)
find_package(NL REQUIRED)

if(NOT IWLIB_H)
message(FATAL_ERROR "Unable to find iwlib.h")
endif(NOT IWLIB_H)

find_library(IWLIB_LIB NAMES iw)

if(NOT IWLIB_LIB)
message(FATAL_ERROR "Unable to find libiw.so")
endif(NOT IWLIB_LIB)
if(NOT NL_FOUND)
message(FATAL_ERROR "Unable to find netlink library")
endif()
if(NOT HAVE_LIBNL_ROUTE)
message(FATAL_ERROR "Unable to find netlink route library")
endif()
if(NOT HAVE_LIBNL_GENL)
message(FATAL_ERROR "Unable to find netlink genl library")
endif()

set(conky_libs ${conky_libs} ${IWLIB_LIB})
check_function_exists(iw_sockets_open IWLIB_SOCKETS_OPEN_FUNC)
set(conky_includes ${conky_includes} ${NL_INCLUDE_DIRS})
set(conky_libs ${conky_libs} ${NL_LIBRARIES})
endif(BUILD_WLAN AND OS_LINUX)

if(BUILD_PORT_MONITORS)
Expand Down
123 changes: 123 additions & 0 deletions cmake/FindNL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Find the native netlink includes and library
#
# If they exist, differentiate between versions 1, 2 and 3.
# Version 1 does not have netlink/version.h
# Version 2 started separating libraries (libnl{,-genl,-route}).
# Version 3 (>= 3.2) started appending the major version number as suffix to
# library names (libnl-3)
#
# NL_INCLUDE_DIRS - where to find libnl.h, etc.
# NL_LIBRARIES - List of libraries when using libnl.
# NL_FOUND - True if libnl found.

# Based on wireshark FindNL:
# https://github.com/wireshark/wireshark/blob/master/cmake/modules/FindNL.cmake
# Modified so it doesn't make any hard requirements for libraries used by the
# project.

if(NL_LIBRARIES AND NL_INCLUDE_DIRS)
# in cache already
SET(NL_FOUND TRUE)
else()
SET( SEARCHPATHS
/opt/local
/sw
/usr
/usr/local
)

find_package(PkgConfig)
pkg_check_modules(NL3 libnl-3.0 libnl-genl-3.0 libnl-route-3.0)
if(NOT NL3_FOUND)
pkg_search_module(NL2 libnl-2.0)
if (NL2_FOUND)
mark_as_advanced(NL2_INCLUDE_DIR NL2_LIBRARY)
endif()
endif()

# Try to find NL 2.0, 3.0 or 3.1 (/usr/include/netlink/version.h) or
# NL >= 3.2 (/usr/include/libnl3/netlink/version.h)
find_path(NL3_INCLUDE_DIR
PATH_SUFFIXES
include/libnl3
include
NAMES
netlink/version.h
HINTS
"${NL3_libnl-3.0_includeDIR}"
"${NL2_includeDIR}"
PATHS
$(SEARCHPATHS)
)

# NL version >= 2
if(NL3_INCLUDE_DIR)
find_library(NL3_LIBRARY
NAMES
nl-3 nl
PATH_SUFFIXES
lib64 lib
HINTS
"${NL3_libnl-3.0_LIBDIR}"
"${NL2_LIBDIR}"
PATHS
$(SEARCHPATHS)
)

if(NL3_LIBRARY)
set(NL_LIBRARIES ${NL_LIBRARIES} ${NL3_LIBRARY})
set(NL_INCLUDE_DIRS ${NL_INCLUDE_DIRS} ${NL3_INCLUDE_DIR})
set(HAVE_LIBNL 1)
mark_as_advanced(NL3_LIBRARY HAVE_LIBNL)
else()

endif()

find_library(NLGENL_LIBRARY
NAMES
nl-genl-3 nl-genl
PATH_SUFFIXES
lib64 lib
HINTS
"${NL3_libnl-genl-3.0_LIBDIR}"
"${NL2_LIBDIR}"
PATHS
$(SEARCHPATHS)
)

if(NLGENL_LIBRARY)
mark_as_advanced(NLGENL_LIBRARY)
set(NL_LIBRARIES ${NL_LIBRARIES} ${NLGENL_LIBRARY})
set(HAVE_LIBNL_GENL 1)
endif()

find_library(NLROUTE_LIBRARY
NAMES
nl-route-3 nl-route
PATH_SUFFIXES
lib64 lib
HINTS
"${NL3_libnl-route-3.0_LIBDIR}"
"${NL2_LIBDIR}"
PATHS
$(SEARCHPATHS)
)

if(NLROUTE_LIBRARY)
mark_as_advanced(NLROUTE_LIBRARY)
set(NL_LIBRARIES ${NL_LIBRARIES} ${NLROUTE_LIBRARY})
set(HAVE_LIBNL_ROUTE 1)
endif()

if(NOT NL3_FOUND AND NL2_FOUND)
set(HAVE_LIBNL2 1)
else()
set(HAVE_LIBNL3 1)
endif()
endif()
endif()

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NL DEFAULT_MSG NL_LIBRARIES NL_INCLUDE_DIRS)
mark_as_advanced(NL_LIBRARIES NL_INCLUDE_DIRS)

5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ if(BUILD_MYSQL)
set(optional_sources ${optional_sources} ${mysql})
endif(BUILD_MYSQL)

if(BUILD_WLAN)
set(netlink-conky netlink-conky.cc netlink-conky.h)
set(optional_sources ${optional_sources} ${netlink-conky})
endif(BUILD_WLAN)

if(BUILD_MOC)
set(moc moc.cc moc.h)
set(optional_sources ${optional_sources} ${moc})
Expand Down
4 changes: 2 additions & 2 deletions src/darwin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -703,14 +703,14 @@ void update_wlan_stats(struct net_stat *ns) {
/*
* Setup
*/
memcpy(ns->essid, essid, sizeof(char)*strlen(essid));
ns->essid = std::string(essid);
ns->channel = interface.wlanChannel.channelNumber;
memcpy(ns->freq, freq, sizeof(char)*strlen(freq));
memcpy(ns->bitrate, bitrate, sizeof(char)*strlen(bitrate));
memcpy(ns->mode, mode, sizeof(char)*strlen(mode));
ns->link_qual = 0;
ns->link_qual_max = 0;
memcpy(ns->ap, ap, sizeof(char)*strlen(ap));
ns->ap = std::string(ap);
}

#endif /* BUILD_WLAN */
Expand Down
4 changes: 2 additions & 2 deletions src/display-x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ void process_surface_events(conky::display_output_x11 *surface,
int pending = XPending(display);
if (pending == 0) return;

DBGP2("Processing %d X11 events...", pending);
// DBGP2("Processing %d X11 events...", pending);

/* handle X events */
while (XPending(display) != 0) {
Expand All @@ -835,7 +835,7 @@ void process_surface_events(conky::display_output_x11 *surface,
if (cookie != nullptr) { free(cookie); }
}

DBGP2("Done processing %d events.", pending);
// DBGP2("Done processing %d events.", pending);
}

void display_output_x11::sigterm_cleanup() {
Expand Down
Loading
Loading