Merge branch 'openwrt:master' into master

This commit is contained in:
Hayzam Sherif 2024-02-27 12:21:34 +04:00 committed by GitHub
commit 711d0a7855
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 179 deletions

View file

@ -1,49 +1,51 @@
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,12 @@ LIBS ?= -lpcap -lstdc++
@@ -2,11 +2,14 @@ LIBS ?= -lpcap -lstdc++
RELEASEFLAGS ?= -O3 -Wall
#CXXFLAGS ?= --std=c++0x
-# auto-detect if bsd/strings.h is available
-ifeq ($(shell $(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEFS) -E -o /dev/null \
- make-checks/libbsd.cpp 2>/dev/null; echo $$?),0)
- BSDSTR_DEFS := -DUSE_BSD_STRING_H
- BSDSTR_LIBS := -lbsd
+# check if libc provides BSD's strlcpy
+ifeq ($(shell $(CXX) $(CXXFLAGS) -D_BSD_SOURCE $(LDFLAGS) $(DEFS) -o /dev/null \
+ make-checks/strlcpy.cpp 2>/dev/null; echo $$?),0)
+ BSDSTR_DEFS := -D_BSD_SOURCE -DUSE_LIBC_STRLCPY
# auto-detect if bsd/strings.h is available
-ifeq ($(shell $(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEFS) -E -o /dev/null \
+else ifeq ($(shell $(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEFS) -E -o /dev/null \
make-checks/libbsd.cpp 2>/dev/null; echo $$?),0)
BSDSTR_DEFS := -DUSE_BSD_STRING_H
BSDSTR_LIBS := -lbsd
+ BSDSTR_DEFS := -D_BSD_SOURCE
+# use libbsd's strlcpy
+else
+ BSDSTR_DEFS != pkg-config --cflags libbsd-overlay
+ BSDSTR_LIBS != pkg-config --libs libbsd-overlay
endif
# auto-detect rhel/fedora and debian/ubuntu
--- a/pcapsipdump_lib.h
+++ b/pcapsipdump_lib.h
@@ -3,7 +3,7 @@
#ifndef BSD
#ifdef USE_BSD_STRING_H
#include <bsd/string.h>
@@ -1,13 +1,5 @@
#include <sys/stat.h>
-#ifndef BSD
- #ifdef USE_BSD_STRING_H
- #include <bsd/string.h>
- #else
+ #elif !defined(USE_LIBC_STRLCPY)
#define strlcpy strncpy
#endif
#endif
- #define strlcpy strncpy
- #endif
-#endif
-
// equivalent of "mkdir -p"
int mkdir_p(const char *path, mode_t mode);
--- a/make-checks/all.mk
+++ b/make-checks/all.mk
@@ -1,5 +1,5 @@
-make-checks/all: make-checks/cxx make-checks/libpcap make-checks/libbsd
+make-checks/all: make-checks/cxx make-checks/libpcap make-checks/strlcpy make-checks/libbsd
+make-checks/all: make-checks/cxx make-checks/libpcap make-checks/strlcpy
@touch make-checks/all
make-checks/clean:
- rm -f make-checks/all make-checks/cxx make-checks/libpcap make-checks/libbsd
+ rm -f make-checks/all make-checks/cxx make-checks/libpcap make-checks/strlcpy make-checks/libbsd
--- a/make-checks/libbsd.mk
+++ b/make-checks/libbsd.mk
@@ -2,5 +2,5 @@ CHECK_LIBBSD = $(CXX) $(CXXFLAGS) $(LDFL
make-checks/libbsd:
@$(CHECK_LIBBSD) || (\
- echo "*** notice: recommended library not found: libbsd"; \
+ echo "*** notice: library not found: libbsd"; \
true)
+ rm -f make-checks/all make-checks/cxx make-checks/libpcap make-checks/strlcpy
--- /dev/null
+++ b/make-checks/strlcpy.cpp
@@ -0,0 +1,6 @@

View file

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sipp
PKG_VERSION:=3.6.1
PKG_RELEASE:=2
PKG_VERSION:=3.7.2
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/SIPp/sipp/releases/download/v$(PKG_VERSION)
PKG_HASH:=6a560e83aff982f331ddbcadfb3bd530c5896cd5b757dd6eb682133cc860ecb1
PKG_HASH:=7c3a9864b3a966ac9f7a3205255a2fc328490de324b7a27636f9582879f0526e
PKG_LICENSE:=GPL-2.0+ BSD-3-Clause Zlib
PKG_LICENSE_FILES:=LICENSE.txt

View file

@ -1,149 +0,0 @@
commit 626de652455a6c061d5a045fb226212c1f7eaeb5
Author: Walter Doekes <walter+github@wjd.nu>
Date: Fri Sep 18 09:56:40 2020 +0200
Fix compatibility with older C++ in 3.6.x branch
- no auto keyword (auto x = 1)
- no range based loop (for (*iter) : iterable)
- no std::to_string
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 111c137..f1f815a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,7 @@ file(GLOB all_SRCS
"${PROJECT_SOURCE_DIR}/src/*.c"
)
+include(${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
include(${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
include(${CMAKE_ROOT}/Modules/CheckStructHasMember.cmake)
@@ -43,6 +44,10 @@ CHECK_STRUCT_HAS_MEMBER("struct udphdr" uh_sport "sys/types.h;netinet/udp.h" HA
CHECK_SYMBOL_EXISTS(le16toh "endian.h" HAVE_DECL_LE16TOH)
CHECK_SYMBOL_EXISTS(le16toh "sys/endian.h" HAVE_DECL_LE16TOH_BSD)
+CHECK_CXX_SOURCE_COMPILES("
+#include <string>
+int main() { std::to_string(1).c_str(); return 0; }
+" HAVE_STD_TOSTRING)
configure_file("${PROJECT_SOURCE_DIR}/include/config.h.in"
"${PROJECT_BINARY_DIR}/config.h" )
diff --git a/include/config.h.in b/include/config.h.in
index 8c22504..cf39ea1 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
- * This file is autogenerated from config.h.in
+ * This file is autogenerated from include/config.h.in
* during the cmake configuration of your project. If you need to make changes
* edit the original file NOT THIS FILE.
* --------------------------------------------------------------------------*/
@@ -18,5 +18,6 @@
#endif
#cmakedefine HAVE_IP_COMPAT_H @HAVE_IP_COMPAT_H@
#cmakedefine HAVE_UDP_UH_PREFIX @HAVE_UDP_UH_PREFIX@
+#cmakedefine HAVE_STD_TOSTRING @HAVE_STD_TOSTRING@
#endif
diff --git a/include/screen.hpp b/include/screen.hpp
index 13a9708..37c8ddf 100644
--- a/include/screen.hpp
+++ b/include/screen.hpp
@@ -43,9 +43,12 @@ void print_statistics(int last);
extern int key_backspace;
extern int key_dc;
+typedef std::vector<std::string> string_array;
+
class ScreenPrinter {
public:
ScreenPrinter():
+ M_last(false),
M_headless(!isatty(fileno(stdout)))
{};
void redraw();
@@ -63,9 +66,9 @@ private:
void draw_repartition_detailed(CStat::T_dynamicalRepartition * tabRepartition,
int sizeOfTab);
- std::vector<std::string> lines;
+ string_array lines;
- bool M_last = false;
+ bool M_last;
};
extern ScreenPrinter* sp;
diff --git a/include/sipp.hpp b/include/sipp.hpp
index 878c99f..b04a619 100644
--- a/include/sipp.hpp
+++ b/include/sipp.hpp
@@ -83,6 +83,18 @@
#include "ratetask.hpp"
#include "watchdog.hpp"
+/* Backwards compatibility */
+#ifndef HAVE_STD_TOSTRING
+#include <sstream>
+namespace std {
+template <typename T> string to_string(T value) {
+ ostringstream os;
+ os << value;
+ return os.str();
+}
+}
+#endif
+
/*
* If this files is included in the Main, then extern definitions
* are removed, and the DEFVAL macro becomes '= value;'. Else
diff --git a/src/screen.cpp b/src/screen.cpp
index bbf9cd2..5521a44 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -83,15 +83,15 @@ void print_statistics(int last)
void ScreenPrinter::print_closing_stats() {
M_last = true;
get_lines();
- for (auto line : lines) {
- printf("%s\n", line.c_str());
+ for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+ printf("%s\n", (*it).c_str());
}
if (currentScreenToDisplay != DISPLAY_STAT_SCREEN) {
currentScreenToDisplay = DISPLAY_STAT_SCREEN;
get_lines();
- for (auto line : lines) {
- printf("%s\n", line.c_str());
+ for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+ printf("%s\n", (*it).c_str());
}
}
@@ -100,8 +100,8 @@ void ScreenPrinter::print_closing_stats() {
void ScreenPrinter::print_to_file(FILE* f)
{
get_lines();
- for (auto line : lines) {
- fprintf(f, "%s\n", line.c_str());
+ for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+ fprintf(f, "%s\n", (*it).c_str());
}
}
@@ -114,8 +114,8 @@ void ScreenPrinter::redraw()
if (!M_headless) {
get_lines();
erase();
- for (auto line : lines) {
- printw("%s\n", line.c_str());
+ for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+ printw("%s\n", (*it).c_str());
}
if (command_mode) {