File 27.patch of Package ngrep

From cfcf1e6e9c4f8a2404810d8d1d90e6d1eaa0abdd Mon Sep 17 00:00:00 2001
From: Romain Francoise <romain@rfr.io>
Date: Sat, 20 Nov 2021 23:28:15 +0100
Subject: [PATCH] Port to PCRE2 API and enable JIT compilation

The original PCRE API provided on most systems by libpcre3 is no longer
maintained upstream and is superseded by the new PCRE2 API, which was
first released in 2015. pcre3 will be removed from Debian in 2023, as
noted in this bug report: https://bugs.debian.org/1000080

This commit replaces the existing PCRE implementation with a new one
using PCRE2, which is quite similar. One benefit is that PCRE2 provides
a JIT compiler which can replace the interpretive regular expression
evaluation code with native machine code on most modern platforms:
https://pcre.org/current/doc/html/pcre2jit.html

Depending on the length and complexity of the pattern used, enabling JIT
compilation makes Ngrep 50x to 150x faster, testing in quiet mode on a
multi-gigabyte PCAP file stored on tmpfs.
---
 configure.in |  24 ++++++------
 ngrep.c      | 106 ++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 82 insertions(+), 48 deletions(-)


--- ngrep-1_47.orig/config.h.in	2017-09-07 23:28:35.000000000 +0200
+++ ngrep-1_47/config.h.in	2022-09-23 08:10:33.493621588 +0200
@@ -1,28 +1,109 @@
-/*
- * Copyright (c) 2017  Jordan Ritter <jpr5@darkridge.com>
- *
- * Please refer to the LICENSE file for more information.
- *
- */
-
-#define USE_PCRE                     @USE_PCRE@
-#define USE_IPv6                     @USE_IPv6@
-#define USE_TCPKILL                  @USE_TCPKILL@
-#define USE_VLAN_HACK                @USE_VLAN_HACK@
-
-#define HAVE_DLT_RAW                 @HAVE_DLT_RAW@
-#define HAVE_DLT_PFLOG               @HAVE_DLT_PFLOG@
-#define HAVE_DLT_LOOP                @HAVE_DLT_LOOP@
-#define HAVE_DLT_LINUX_SLL           @HAVE_DLT_LINUX_SLL@
-#define HAVE_DLT_IEEE802_11          @HAVE_DLT_IEEE802_11@
-#define HAVE_DLT_IEEE802_11_RADIO    @HAVE_DLT_IEEE802_11_RADIO@
-#define HAVE_DLT_IPNET               @HAVE_DLT_IPNET@
-
-#define USE_PCAP_RESTART             @USE_PCAP_RESTART@
-#if USE_PCAP_RESTART
-#define PCAP_RESTART_FUNC            @PCAP_RESTART_FUNC@
-extern void PCAP_RESTART_FUNC();
-#endif
+/* config.h.in.  Generated from configure.in by autoheader.  */
 
-#define USE_DROPPRIVS                @USE_DROPPRIVS@
-#define DROPPRIVS_USER               @DROPPRIVS_USER@
+/* pseudo-user for running ngrep (default "nobody") */
+#undef DROPPRIVS_USER
+
+/* presence of DLT_IEEE802_11 in bpf.h */
+#undef HAVE_DLT_IEEE802_11
+
+/* presence of DLT_IEEE802_11_RADIO in bpf.h */
+#undef HAVE_DLT_IEEE802_11_RADIO
+
+/* presence of DLT_IPNET in bpf.h */
+#undef HAVE_DLT_IPNET
+
+/* presence of DLT_LINUX_SLL in bpf.h */
+#undef HAVE_DLT_LINUX_SLL
+
+/* presence of DLT_LOOP in bpf.h */
+#undef HAVE_DLT_LOOP
+
+/* presence of DLT_PFLOG in $BPF */
+#undef HAVE_DLT_PFLOG
+
+/* presence of DLT_RAW in bpf.h */
+#undef HAVE_DLT_RAW
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `net' library (-lnet). */
+#undef HAVE_LIBNET
+
+/* Define to 1 if you have the `nsl' library (-lnsl). */
+#undef HAVE_LIBNSL
+
+/* Define to 1 if you have the `pcap' library (-lpcap). */
+#undef HAVE_LIBPCAP
+
+/* Define to 1 if you have the `socket' library (-lsocket). */
+#undef HAVE_LIBSOCKET
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* routine used for restarting the BPF lexer */
+#undef PCAP_RESTART_FUNC
+
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
+#undef STDC_HEADERS
+
+/* whether to use privileges dropping (default yes) */
+#undef USE_DROPPRIVS
+
+/* whether to use IPv6 (default off) */
+#undef USE_IPv6
+
+/* whether to call the BPF lexer restart function between multiple BPF filter
+   compilation attempts (default no) */
+#undef USE_PCAP_RESTART
+
+/* whether to use PCRE2 (default GNU Regex) */
+#undef USE_PCRE2
+
+/* whether to enable tcpkill functionality (default off) */
+#undef USE_TCPKILL
+
+/* whether to automatically include VLAN frames (default on) */
+#undef USE_VLAN_HACK
--- ngrep-1_47.orig/configure	2017-09-07 23:28:35.000000000 +0200
+++ ngrep-1_47/configure	2022-09-23 08:10:33.333621888 +0200
@@ -1,9 +1,10 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69.
+# Generated by GNU Autoconf 2.71.
 #
 #
 -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
+# Inc.
 #'
openSUSE Build Service is sponsored by