aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore10
-rw-r--r--.travis.yml25
-rw-r--r--Makefile.am1
-rw-r--r--README.md2
-rw-r--r--configure.ac49
-rwxr-xr-xcontrib/jenkins.sh20
-rw-r--r--contrib/osmo-pcap.spec.in8
-rw-r--r--contrib/systemd/osmo-pcap-client.service4
-rw-r--r--contrib/systemd/osmo-pcap-server.service4
-rwxr-xr-xcontrib/travis.sh27
-rw-r--r--debian/changelog117
-rw-r--r--debian/compat2
-rw-r--r--debian/control14
-rw-r--r--debian/copyright2
-rw-r--r--doc/Makefile.am5
-rw-r--r--doc/examples/osmo-pcap-client/osmo-pcap-client-tls.cfg8
-rw-r--r--doc/examples/osmo-pcap-client/osmo-pcap-client.cfg8
-rw-r--r--doc/examples/osmo-pcap-server/osmo-pcap-server-tls.cfg5
-rw-r--r--doc/examples/osmo-pcap-server/osmo-pcap-server.cfg5
-rw-r--r--doc/manuals/Makefile.am18
-rw-r--r--doc/manuals/chapters/client.adoc132
-rw-r--r--doc/manuals/chapters/overview.adoc43
-rw-r--r--doc/manuals/chapters/server.adoc90
-rw-r--r--doc/manuals/osmopcap-usermanual-docinfo.xml47
-rw-r--r--doc/manuals/osmopcap-usermanual.adoc32
-rw-r--r--doc/manuals/vty/Makefile.vty-reference.inc37
-rw-r--r--doc/manuals/vty/osmo-pcap-vty-reference.xml35
-rw-r--r--doc/manuals/vty/vty_additions.xml2
-rw-r--r--include/osmo-pcap/common.h4
-rw-r--r--include/osmo-pcap/osmo_pcap_client.h4
-rw-r--r--include/osmo-pcap/osmo_pcap_server.h3
-rw-r--r--osmoappdesc.py4
-rw-r--r--src/Makefile.am2
-rw-r--r--src/osmo_client_core.c12
-rw-r--r--src/osmo_client_main.c64
-rw-r--r--src/osmo_client_network.c27
-rw-r--r--src/osmo_client_vty.c23
-rw-r--r--src/osmo_common.c16
-rw-r--r--src/osmo_server_main.c63
-rw-r--r--src/osmo_server_network.c22
-rw-r--r--src/osmo_server_vty.c44
-rw-r--r--tests/Makefile.am5
42 files changed, 893 insertions, 152 deletions
diff --git a/.gitignore b/.gitignore
index dd48c7d..274543c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ install-sh
missing
stamp-h1
compile
+configure~
osmopcapconfig.h*
@@ -37,3 +38,12 @@ tests/testsuite
tests/testsuite.log
contrib/osmo-pcap.spec
+
+# manuals
+doc/manuals/generated/
+doc/manuals/vty/osmo-pcap-*-vty-reference.pdf
+doc/manuals/vty/osmo-pcap-*-vty-reference.xml
+doc/manuals/vty/osmo-pcap-*-vty-reference.xml.inc.gen
+doc/manuals/vty/osmo-pcap-*-vty-reference.xml.inc.merged
+doc/manuals/common
+doc/manuals/build
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index ebec2d9..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-language: c
-os:
- - linux
-sudo: required
-dist: trusty
-addons:
- apt:
- packages:
- - autoconf
- - automake
- - make
- - gcc
- - debhelper
- - devscripts
- - libtool
- - build-essential
- - pkg-config
- - libtalloc-dev
- - libpcsclite-dev
- - libpcap-dev
- - libzmq3-dev
- - libgnutls28-dev
-
-script:
- - contrib/travis.sh
diff --git a/Makefile.am b/Makefile.am
index 3040616..f793b34 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,6 +5,7 @@ SUBDIRS = include src contrib doc tests
BUILT_SOURCES = $(top_srcdir)/.version
EXTRA_DIST = \
.version \
+ README.md \
contrib/osmo-pcap.spec.in \
debian \
git-version-gen \
diff --git a/README.md b/README.md
index 791e28f..fc1cfd5 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# osmo-pcap distributed network capture
osmo-pcap has been created to collect network traces at different nodes
-but store them centrally at a dedicated note for further analysis. This
+but store them centrally at a dedicated node for further analysis. This
might be needed for auditing, resolving conflicts, post processing or
debugging a distributed system.
diff --git a/configure.ac b/configure.ac
index 6660bf1..8a27118 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,6 +5,46 @@ AC_INIT([osmo-pcap],
AM_INIT_AUTOMAKE([dist-bzip2])
AC_CONFIG_TESTDIR(tests)
+AC_ARG_ENABLE(manuals,
+ [AS_HELP_STRING(
+ [--enable-manuals],
+ [Generate manual PDFs [default=no]],
+ )],
+ [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
+AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
+AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
+ fallback])
+if test x"$osmo_ac_build_manuals" = x"yes"
+then
+ # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
+ if test -n "$OSMO_GSM_MANUALS_DIR"; then
+ echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
+ else
+ OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
+ if test -n "$OSMO_GSM_MANUALS_DIR"; then
+ echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
+ else
+ OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
+ echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
+ fi
+ fi
+ if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
+ AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
+ fi
+
+ # Find and run check-depends
+ CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
+ if ! test -x "$CHECK_DEPENDS"; then
+ CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
+ fi
+ if ! $CHECK_DEPENDS; then
+ AC_MSG_ERROR("missing dependencies for --enable-manuals")
+ fi
+
+ # Put in Makefile with absolute path
+ OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
+ AC_SUBST([OSMO_GSM_MANUALS_DIR])
+fi
CFLAGS="$CFLAGS -std=gnu11"
@@ -117,9 +157,11 @@ AC_SUBST([PCAP_LIBS])
AC_SUBST([PCAP_CFLAGS])
dnl checks for libraries
-PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.11.0)
-PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.11.0)
-PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.11.0)
+PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
+# libosmogb: needed for osmocom/gprs includes
+PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 1.9.0)
+PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.9.0)
+PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.9.0)
PKG_CHECK_MODULES(LIBZMQ, libzmq >= 3.2.2)
PKG_CHECK_MODULES(LIBGNUTLS, gnutls)
@@ -150,5 +192,6 @@ AC_OUTPUT(
contrib/osmo-pcap.spec
doc/Makefile
doc/examples/Makefile
+ doc/manuals/Makefile
tests/Makefile
Makefile)
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index f1779dc..683fb9d 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -24,6 +24,13 @@ export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$inst/lib"
osmo-build-dep.sh libosmocore "" '--disable-doxygen --enable-gnutls'
+# Additional configure options and depends
+CONFIG=""
+if [ "$WITH_MANUALS" = "1" ]; then
+ osmo-build-dep.sh osmo-gsm-manuals
+ CONFIG="--enable-manuals"
+fi
+
set +x
echo
echo
@@ -35,12 +42,21 @@ set -x
cd "$base"
autoreconf --install --force
-PCAP_LIBS="-lpcap" PCAP_CFLAGS="" ./configure --with-pcap-config=/bin/true --enable-sanitize --enable-werror
+PCAP_LIBS="-lpcap" PCAP_CFLAGS="" ./configure \
+ --with-pcap-config=/bin/true \
+ --enable-sanitize \
+ --enable-werror \
+ $CONFIG
$MAKE $PARALLEL_MAKE
$MAKE check || cat-testlogs.sh
-DISTCHECK_CONFIGURE_FLAGS="--with-pcap-config=/bin/true" \
+DISTCHECK_CONFIGURE_FLAGS="--with-pcap-config=/bin/true $CONFIG" \
PCAP_LIBS="-lpcap" PCAP_CFLAGS="" \
$MAKE distcheck || cat-testlogs.sh
+
+if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
+ make -C "$base/doc/manuals" publish
+fi
+
$MAKE maintainer-clean
osmo-clean-workspace.sh
diff --git a/contrib/osmo-pcap.spec.in b/contrib/osmo-pcap.spec.in
index 2755afa..0aa079a 100644
--- a/contrib/osmo-pcap.spec.in
+++ b/contrib/osmo-pcap.spec.in
@@ -29,10 +29,10 @@ BuildRequires: systemd-rpm-macros
%endif
BuildRequires: pkgconfig
BuildRequires: pkgconfig(gnutls)
-BuildRequires: pkgconfig(libosmocore) >= 0.11.0
-BuildRequires: pkgconfig(libosmogb)
-BuildRequires: pkgconfig(libosmogsm) >= 0.11.0
-BuildRequires: pkgconfig(libosmovty) >= 0.11.0
+BuildRequires: pkgconfig(libosmocore) >= 1.9.0
+BuildRequires: pkgconfig(libosmogb) >= 1.9.0
+BuildRequires: pkgconfig(libosmogsm) >= 1.9.0
+BuildRequires: pkgconfig(libosmovty) >= 1.9.0
BuildRequires: pkgconfig(libzmq) >= 3.2.2
%{?systemd_requires}
diff --git a/contrib/systemd/osmo-pcap-client.service b/contrib/systemd/osmo-pcap-client.service
index fd0de75..c79fafc 100644
--- a/contrib/systemd/osmo-pcap-client.service
+++ b/contrib/systemd/osmo-pcap-client.service
@@ -1,9 +1,13 @@
[Unit]
Description=PCAP Client for the PCAP aggregation
+After=network-online.target
+Wants=network-online.target
[Service]
Type=simple
Restart=always
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
ExecStart=/usr/bin/osmo-pcap-client -c /etc/osmocom/osmo-pcap-client.cfg
RestartSec=2
diff --git a/contrib/systemd/osmo-pcap-server.service b/contrib/systemd/osmo-pcap-server.service
index 3094fc4..a6b6822 100644
--- a/contrib/systemd/osmo-pcap-server.service
+++ b/contrib/systemd/osmo-pcap-server.service
@@ -1,9 +1,13 @@
[Unit]
Description=PCAP Server for the PCAP aggregation
+After=network-online.target
+Wants=network-online.target
[Service]
Type=simple
Restart=always
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
ExecStart=/usr/bin/osmo-pcap-server -c /etc/osmocom/osmo-pcap-server.cfg
RestartSec=2
diff --git a/contrib/travis.sh b/contrib/travis.sh
deleted file mode 100755
index 4614414..0000000
--- a/contrib/travis.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-rm -rf deps/install
-mkdir deps || true
-cd deps
-git clone git://git.osmocom.org/libosmocore
-
-cd libosmocore
-git reset --hard 460f9ef7da1db11b104fdfe635ebcbd8a071f205
-autoreconf --install --force
-./configure --prefix=$PWD/../install
-make -j 4 install
-export LD_LIBRARY_PATH=$PWD/../install/lib
-
-cd ../
-git clone git://git.osmocom.org/python/osmo-python-tests
-cd osmo-python-tests
-sudo ./setup.py install
-
-cd ../../
-autoreconf --install --force
-PCAP_LIBS="-lpcap" PCAP_CFLAGS="" PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig ./configure --with-pcap-config=/bin/true --enable-external-tests
-PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig make -j 4
-PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig make check
-DISTCHECK_CONFIGURE_FLAGS="--with-pcap-config=/bin/true" PCAP_LIBS="-lpcap" PCAP_CFLAGS="" PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig LD_LIBRARY_PATH=$PWD/deps/install/lib make distcheck
diff --git a/debian/changelog b/debian/changelog
index 14a0d0e..4f67187 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,120 @@
+osmo-pcap (0.4.2) unstable; urgency=medium
+
+ [ arehbein ]
+ * Transition to use of 'telnet_init_default'
+
+ [ Daniel Willmann ]
+ * osmo_{client,server}_main: Remove tall_ctr_ctx and tall_msgb_ctx
+ * osmo_{client,server}_main: Remove is_config_node in vty_app_info
+ * cosmetic: Remove trailing whitespace
+
+ [ Pau Espin Pedrol ]
+ * server: Call osmo_fd_unregister() before closing and changing bfd->fd
+
+ [ Max ]
+ * CI/CD: drop travis support
+
+ [ Oliver Smith ]
+ * debian: set compat level to 10
+ * systemd: depend on networking-online.target
+
+ [ Vadim Yanitskiy ]
+ * tests: $(BUILT_SOURCES) is not defined
+
+ -- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 12 Sep 2023 15:50:49 +0200
+
+osmo-pcap (0.4.1) unstable; urgency=medium
+
+ [ Max ]
+ * Set working directory in systemd service file
+
+ [ Vadim Yanitskiy ]
+ * doc/manuals: update git URLs (git -> https; gitea)
+
+ -- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 07 Feb 2023 17:11:46 +0100
+
+osmo-pcap (0.4.0) unstable; urgency=medium
+
+ [ Pau Espin Pedrol ]
+ * client: Increase wqueue transmit length
+ * client: Log wqueue capacity when failing to enqueue
+ * client: Add 'wqueue max-length <0-4294967295>' VTY command
+ * .gitignore: blacklist configure~
+
+ [ Harald Welte ]
+ * update git URLs (git -> https; gitea)
+
+ -- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 28 Jun 2022 17:36:44 +0200
+
+osmo-pcap (0.3.0) unstable; urgency=medium
+
+ [ Vadim Yanitskiy ]
+ * debian/control: minimum version for libzmq3-dev is 3.2.2
+
+ [ Harald Welte ]
+ * configure.ac: don't depend on libosmogb.
+
+ [ Oliver Smith ]
+ * Revert "configure.ac: don't depend on libosmogb."
+
+ [ Pau Espin Pedrol ]
+ * server: Add vty command file-permission-mask
+
+ -- Pau Espin Pedrol <pespin@sysmocom.de> Thu, 13 Jan 2022 10:06:14 +0100
+
+osmo-pcap (0.2.1) unstable; urgency=medium
+
+ [ Pau Espin Pedrol ]
+ * Use new stat item/ctr getter APIs
+ * Explicitly depend on required libosmogb
+
+ [ Oliver Smith ]
+ * README.md: fix typo
+ * Change default ports of client, server
+
+ -- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 16 Nov 2021 13:40:07 +0100
+
+osmo-pcap (0.2.0) unstable; urgency=medium
+
+ [ Harald Welte ]
+ * vty: Add space after prompt, as customary
+ * add "--version" to osmo-pcap-client and -server
+ * update copyright statement; Holger worked on it until 2017
+ * Add user manual for osmo-pcap
+ * use osmo_wqueue_enqueue_quiet() as we log anyway
+ * client: Ensure the "file" header is sent on connect
+ * use telnet_init_dynif() to allow VTY bind to non-loopack address
+ * vty: call telnet_init_dynif() after config file is read
+
+ [ Joachim Steiger ]
+ * manuals: generate VTY reference for osmo-pcap-{client,server}
+
+ [ Vadim Yanitskiy ]
+ * vty: register commands for talloc context introspection
+ * vty_{client,server}_init(): remove unused argument
+ * contrib/jenkins.sh: fix: pass '--enable-manuals' to configure
+
+ -- Harald Welte <laforge@osmocom.org> Sat, 24 Apr 2021 23:03:34 +0200
+
+osmo-pcap (0.1.3) unstable; urgency=medium
+
+ [ Oliver Smith ]
+ * contrib: import RPM spec
+ * contrib: integrate RPM spec
+ * Makefile.am: EXTRA_DIST: debian, contrib/*.spec.in
+ * configure.ac: set -std=gnu11
+
+ [ Harald Welte ]
+ * Use OSMO_FD_* instead of deprecated BSC_FD_*
+ * Use osmo_fd_setup() whenever applicable
+ * Use osmo_fd_*_{disable,enable}
+ * reformat debian/control for osmo-release.sh compatibility
+
+ [ Pau Espin Pedrol ]
+ * main: generate coredump and exit upon SIGABRT received
+
+ -- Pau Espin Pedrol <pespin@espeweb.net> Tue, 23 Feb 2021 13:19:37 +0100
+
osmo-pcap (0.1.2) unstable; urgency=medium
[ Oliver Smith ]
diff --git a/debian/compat b/debian/compat
index ec63514..f599e28 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-9
+10
diff --git a/debian/control b/debian/control
index 4e2fc7c..846998b 100644
--- a/debian/control
+++ b/debian/control
@@ -1,19 +1,19 @@
Source: osmo-pcap
-Section: unknown
+Section: net
Priority: extra
-Maintainer: Holger Hans Peter Freyther <zecke@selfish.org>
-Build-Depends: debhelper (>= 7.0.50~),
+Maintainer: Osmocom team <openbsc@lists.osmocom.org>
+Build-Depends: debhelper (>= 10),
dh-autoreconf,
autotools-dev,
libpcap0.8-dev,
pkg-config,
- libosmocore-dev,
+ libosmocore-dev (>= 1.9.0),
libgnutls28-dev,
- libzmq3-dev
+ libzmq3-dev (>= 3.2.2)
Standards-Version: 3.9.1
Homepage: https://osmocom.org/projects/osmo-pcap
-Vcs-Git: git://git.osmocom.org/osmo-pcap.git
-Vcs-Browser: http://git.osmocom.org/osmo-pcap/
+Vcs-Git: https://gitea.osmocom.org/osmocom/osmo-pcap
+Vcs-Browser: https://gitea.osmocom.org/osmocom/osmo-pcap
Package: osmo-pcap-client
Architecture: any
diff --git a/debian/copyright b/debian/copyright
index 9731a49..d4e0ee7 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,6 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OsmoPCAP
-Source: http://cgit.osmocom.org/osmo-pcap/
+Source: https://gitea.osmocom.org/osmocom/osmo-pcap
Files: *
Copyright: 2011 Holger Freyther and On-Waves
diff --git a/doc/Makefile.am b/doc/Makefile.am
index aee2d7b..f04764f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1 +1,4 @@
-SUBDIRS = examples
+SUBDIRS = \
+ examples \
+ manuals \
+ $(NULL)
diff --git a/doc/examples/osmo-pcap-client/osmo-pcap-client-tls.cfg b/doc/examples/osmo-pcap-client/osmo-pcap-client-tls.cfg
index 73d1535..6249f2a 100644
--- a/doc/examples/osmo-pcap-client/osmo-pcap-client-tls.cfg
+++ b/doc/examples/osmo-pcap-client/osmo-pcap-client-tls.cfg
@@ -3,6 +3,14 @@
!!
!
!
+log stderr
+ logging color 1
+ logging print category-hex 0
+ logging print category 1
+ logging timestamp 0
+ logging print file basename last
+ logging print level 1
+
line vty
no login
!
diff --git a/doc/examples/osmo-pcap-client/osmo-pcap-client.cfg b/doc/examples/osmo-pcap-client/osmo-pcap-client.cfg
index 829ae5d..7035099 100644
--- a/doc/examples/osmo-pcap-client/osmo-pcap-client.cfg
+++ b/doc/examples/osmo-pcap-client/osmo-pcap-client.cfg
@@ -3,6 +3,14 @@
!!
!
!
+log stderr
+ logging color 1
+ logging print category-hex 0
+ logging print category 1
+ logging timestamp 0
+ logging print file basename last
+ logging print level 1
+
line vty
no login
!
diff --git a/doc/examples/osmo-pcap-server/osmo-pcap-server-tls.cfg b/doc/examples/osmo-pcap-server/osmo-pcap-server-tls.cfg
index 52f66f5..db055d4 100644
--- a/doc/examples/osmo-pcap-server/osmo-pcap-server-tls.cfg
+++ b/doc/examples/osmo-pcap-server/osmo-pcap-server-tls.cfg
@@ -4,7 +4,11 @@
!
log stderr
logging color 1
+ logging print category-hex 0
+ logging print category 1
logging timestamp 0
+ logging print file basename last
+ logging print level 1
logging level all everything
logging level pcap notice
logging level client notice
@@ -16,6 +20,7 @@ line vty
!
server
base-path /tmp
+ file-permission-mask 0440
server ip 127.0.0.1
server port 6001
max-file-size 262144000
diff --git a/doc/examples/osmo-pcap-server/osmo-pcap-server.cfg b/doc/examples/osmo-pcap-server/osmo-pcap-server.cfg
index 2f4123a..abfae61 100644
--- a/doc/examples/osmo-pcap-server/osmo-pcap-server.cfg
+++ b/doc/examples/osmo-pcap-server/osmo-pcap-server.cfg
@@ -4,7 +4,11 @@
!
log stderr
logging color 1
+ logging print category-hex 0
+ logging print category 1
logging timestamp 0
+ logging print file basename last
+ logging print level 1
logging level all everything
logging level pcap notice
logging level client notice
@@ -16,6 +20,7 @@ line vty
!
server
base-path /tmp
+ file-permission-mask 0440
server ip 127.0.0.1
server port 6001
max-file-size 262144000
diff --git a/doc/manuals/Makefile.am b/doc/manuals/Makefile.am
new file mode 100644
index 0000000..f2ffa29
--- /dev/null
+++ b/doc/manuals/Makefile.am
@@ -0,0 +1,18 @@
+EXTRA_DIST = osmopcap-usermanual.adoc \
+ osmopcap-usermanual-docinfo.xml \
+ chapters \
+ vty
+
+if BUILD_MANUALS
+ ASCIIDOC = osmopcap-usermanual.adoc
+ ASCIIDOC_DEPS = $(srcdir)/chapters/*.adoc
+ include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.asciidoc.inc
+
+ # This is a significantly modified, multi-target adopted copy of
+ # $(OSMO_GSM_MANUALS_DIR)/build/Makefile.vty-reference.inc
+ VARIANTS = client server
+ include $(srcdir)/vty/Makefile.vty-reference.inc
+
+ OSMO_REPOSITORY = osmo-pcap
+ include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.common.inc
+endif
diff --git a/doc/manuals/chapters/client.adoc b/doc/manuals/chapters/client.adoc
new file mode 100644
index 0000000..f6ceac5
--- /dev/null
+++ b/doc/manuals/chapters/client.adoc
@@ -0,0 +1,132 @@
+== osmo-pcap-client
+
+The osmo-pcap-client program runs at a location of your network
+where you would like to record some packets. It captures those
+packets (with or without filter) and forwards them to one or multiple
+remote servers.
+
+=== Running osmo-pcap-client
+
+==== SYNOPSIS
+
+*osmo-pcap-client* [-D] [-c CFG_FILE] | -h | -V
+
+==== OPTIONS
+
+*-h, --help*::
+ Print a short help message about the supported options.
+*-V, --version*::
+ Print the compile-time version number of the program.
+*-D, --daemonize*::
+ Fork the process as a daemon into background.
+*-c, --config-file 'CONFIGFILE'*::
+ Specify the file and path name of the configuration file to be
+ used. If none is specified, use `osmo-pcap-client.cfg` in the current
+ working directory.
+
+Capturing network packets requires you to be superuser or have the CAP_NET_RAW capability.
+
+There are several options to achieve this:
+
+- start the program as root user (strongly discouraged)
+- globally enable the CAP_NET_RAW capability for the program using e.g. the tool `setcap`
+- asking `systemd` to start the program with the required capability
+
+NOTE:: This potentially opens a privilege escalation, as `osmo-pcap-client` can be configured
+via the VTY interface (telnet) which is by default accessible by any user on the local machine (access to the loopback device). Please make sure to protect access to the VTY interface accordingly.
+
+
+=== Configuring the packet capture
+
+The VTY configuration node of osmo-pcap-client contains a `client` node,
+in which the packet capturing is configured
+
+.osmo-pcap-client VTY configuration for packet capture
+----
+client
+ pcap device eth0 <1>
+ pcap filter udp port 23000 <2>
+ pcap detect-loop 1 <3>
+----
+<1> the network device from which to obtain a capture
+<2> the libpcap filter string (`udp port 23000` in this example)
+<3> instruct osmo-pcap-client to automatically add a filter that prevents capturing
+ the traffic between osmo-pcap-client and osmo-pcap-server, which would create a loop.
+
+
+=== Configuring the primary server
+
+.osmo-pcap-client configuration for the primary remote server
+----
+client
+ server ip 192.168.11.20 <1>
+ server port 54321 <2>
+ source ip 192.168.11.1 <3>
+----
+<1> IP address of the server to which to send the traces
+<2> port number of the server to which to send the traces
+<3> local IP address to use when sending traffic to the server
+
+By default, a custom osmo-pcap specific protocol is used to transport
+the captured packets from client to server. However, the `protocol`
+VTY configuration command can be used to switch to to using a simple `ipip`
+encapsulation. `ipip` can be transparently decoded by protocol analysis
+tools like wireshark.
+
+
+=== Configuring additional servers
+
+In some use cases, you may want to send the captured packets to multiple
+remote destinations.
+
+The primary and each of the remote destinations each receive a copy
+of each captured packet.
+
+.osmo-pcap-client configuration for an additional remote server
+----
+client
+ pcap-store-connection my_server <1>
+ server ip 192.168.11.10 <2>
+ server port 54321 <3>
+ source ip 192.168.11.1 <4>
+ connect <5>
+----
+<1> a human-readable identifier for this specific connection (`my_server`)
+<2> IP address of the server to which to send the traces
+<3> port number of the server to which to send the traces
+<4> local IP address to use when sending traffic to the server
+<5> request connection to the remote server specified in this section
+
+
+=== Configuring TLS
+
+By default, the captured packets are sent in plain-text without any additional
+layer of encryption or authentication. This means that there is no confidentiality,
+nor any integrity protection, unless the original captured packet already featured
+such properties.
+
+If desired, `osmo-pcap-client` can be configured to use TLS (transport layer security)
+on the protocol between client and server.
+
+TLS is configured separately for each remote server, whether primary or additional.
+
+.osmo-pcap-client configuration with TLS
+----
+client
+ server ip 192.168.11.20
+ server port 54321
+ source ip 192.168.11.1
+ enable tls <1>
+ tls hostname pcapserver.example.test<2>
+ tls verify-cert <3>
+ tls capath /etc/osmo-pcap/ca-certificates <4>
+ tls client-cert /etc/osmo-pcap/client.crt <5>
+ tls client-key /etc/osmo-pcap/client.key <6>
+----
+<1> enable TLS for this server
+<2> set the hostname we expect the server to have a certificate for
+<3> enable certificate verification
+<4> path of all CA certificates we consider valid for signing the server cert
+<5> file containing the client certificate
+<6> file containing the private key for the client certificate
+
diff --git a/doc/manuals/chapters/overview.adoc b/doc/manuals/chapters/overview.adoc
new file mode 100644
index 0000000..96bbe4b
--- /dev/null
+++ b/doc/manuals/chapters/overview.adoc
@@ -0,0 +1,43 @@
+[[overview]]
+== OsmoPCAP Overview
+
+=== Package Capturing in distributed telecoms networks
+
+Obtaining raw, binary protocol traces [for later analysis] is an
+essential capability in order to investigate any kind of problem
+in any computer networking system.
+
+The very distributed, heterogenuous nature of cellular networks
+(compared to end-to-end IP networks) results in a lot of relevant
+information being present only at some specific interfaces / points
+in the network. This in turn means that packet captures have to
+be performed at a variety of different network elements in order
+to get the full picture of what is happening.
+
+Recording protocol traces at various different points in the network
+inevitably raises the question of how to aggregate these.
+
+[[about]]
+=== About OsmoPCAP
+
+OsmoPCAP is a software suite consisting of two programs, a client and a
+server component.
+
+- osmo-pcap-client obtains protocol traces by using AF_PACKET sockets,
+ optionally with a capture filter. It then forwards the captures to
+ a remote server.
+- osmo-pcap-server accepts incoming connections from clients. It
+ receives captured packets from those clients and stores them.
+
+The server and client communicate using a custom, TCP based protocol
+for passing captured packets from client to server. Based on your
+configuration, it can optionally be secured by TLS transport-level
+encryption and authentication.
+
+NOTE:: The osmo-pcap programs runs as normal, single-threaded userspace
+programs, without any specific emphasis on efficiency. It doesn't use
+any of the advanced zero-copy mechanisms available on many modern OSs.
+The goal is to capture telecom signaling (control plane) traffic, whose
+bandwidth is (unlike that of the user plane) typically relatively low
+compared to the available CPU / IO speeds. Don't expect osmo-pcap to
+handle wire-rate multi-gigabit throughput.
diff --git a/doc/manuals/chapters/server.adoc b/doc/manuals/chapters/server.adoc
new file mode 100644
index 0000000..4f60880
--- /dev/null
+++ b/doc/manuals/chapters/server.adoc
@@ -0,0 +1,90 @@
+== osmo-pcap-server
+
+The osmo-pcap-server program can run anywhere in your network, as long
+as it can be reached by the remote osmo-pcap-client instances.
+
+=== Running osmo-pcap-server
+
+==== SYNOPSIS
+
+*osmo-pcap-server* [-D] [-c CFG_FILE] | -h | -V
+
+==== OPTIONS
+
+*-h, --help*::
+ Print a short help message about the supported options.
+*-V, --version*::
+ Print the compile-time version number of the program.
+*-D, --daemonize*::
+ Fork the process as a daemon into background.
+*-c, --config-file 'CONFIGFILE'*::
+ Specify the file and path name of the configuration file to be
+ used. If none is specified, use `osmo-pcap-client.cfg` in the current
+ working directory.
+
+As osmo-pcap-server doesn't capture any packets itself and only receives streams of
+captured packets from [remote] osmo-pcap-clients, there is no need to run it as root
+or with elevated privileges.
+
+=== Configuring osmo-pcap-server
+
+The osmo-pcap-server configuration consists mainly of the following parts:
+
+* the global server configuration, optionally including TLS related settings
+* the per-client (per-connection) configuration
+
+.osmo-pcap-server example global configuration
+----
+server
+ base-path /var/lib/osmo-pcap-server <1>
+ server ip 192.168.11.20 <2>
+ server port 54321 <3>
+ max-file-size 100000000 <4>
+ max-snaplen 100000 <5>
+----
+<1> directory to which the pcap files are stored
+<2> IP address to which to bind/listen
+<3> TCP port number to which to bind/listen
+<4> maximum size for pcap files; create a new file once max-file-size is reached
+<5> maximum pcap snapshot length (per packet, in bytes; default: 9000)
+
+The received packets are stored to a pcap file below the `base-path` using a filename
+encoding both the client name and the date/time at time of file creation.
+
+.osmo-pcap-server example global configuration
+----
+server
+ client foo 192.168.100.1 <1>
+ client bar 192.168.200.2 tls <2>
+----
+<1> Client `foo` connects from 192.168.100.1 and uses no TLS
+<2> Client `bar` connects from 192.168.2.00.2 and uses TLS
+
+=== Configuring TLS
+
+By default, the captured packets are received in plain-text without any additional
+layer of encryption or authentication. This means that there is no confidentiality,
+nor any integrity protection, unless the original captured packet already featured
+such properties.
+
+If desired, `osmo-pcap-server` can be configured to use TLS (transport layer security)
+on the protocol between client and server.
+
+TLS is configured separately for each remote server, whether primary or additional.
+
+NOTE:: osmo-pcap-server uses the gnutls library for TLS support. See its documentation in terms of supported file formats for CRL, certificates, keys, etc.
+
+.osmo-pcap-server configuration with TLS
+----
+server
+ tls allow-auth x509 <1>
+ tls capath /etc/osmocom/osmo-pcap-ca <2>
+ tls crlfile /etc/osmocom/osmo-pcap-ca.crl <3>
+ tls server-cert /etc/osmocom/osmo-pcap-server.crt <4>
+ tls server-key /etc/osmocom/osmo-pcap-server.key <5>
+----
+<1> require clients to authenticate using a X.509 client certificate
+<2> path of all CA certificates we consider valid for signing the client cert
+<3> file containing the certificate revocation list
+<4> file containing the server certificate
+<5> file containing the private key for the server certificate
diff --git a/doc/manuals/osmopcap-usermanual-docinfo.xml b/doc/manuals/osmopcap-usermanual-docinfo.xml
new file mode 100644
index 0000000..cede5ab
--- /dev/null
+++ b/doc/manuals/osmopcap-usermanual-docinfo.xml
@@ -0,0 +1,47 @@
+<revhistory>
+ <revision>
+ <revnumber>1</revnumber>
+ <date>January 4th, 2021</date>
+ <authorinitials>HW</authorinitials>
+ <revremark>
+ Initial version
+ </revremark>
+ </revision>
+</revhistory>
+
+<authorgroup>
+ <author>
+ <firstname>Harald</firstname>
+ <surname>Welte</surname>
+ <email>hwelte@sysmocom.de</email>
+ <authorinitials>HW</authorinitials>
+ <affiliation>
+ <shortaffil>sysmocom</shortaffil>
+ <orgname>sysmocom - s.f.m.c. GmbH</orgname>
+ <jobtitle>Managing Director</jobtitle>
+ </affiliation>
+ </author>
+</authorgroup>
+
+<copyright>
+ <year>2021</year>
+ <holder>sysmocom - s.f.m.c. GmbH</holder>
+</copyright>
+
+<legalnotice>
+ <para>
+ Permission is granted to copy, distribute and/or modify this
+ document under the terms of the GNU Free Documentation License,
+ Version 1.3 or any later version published by the Free Software
+ Foundation; with the Invariant Sections being just 'Foreword',
+ 'Acknowledgements' and 'Preface', with no Front-Cover Texts,
+ and no Back-Cover Texts. A copy of the license is included in
+ the section entitled "GNU Free Documentation License".
+ </para>
+ <para>
+ The Asciidoc source code of this manual can be found at
+ <ulink url="https://gitea.osmocom.org/cellular-infrastructure/osmo-gsm-manuals">
+ https://gitea.osmocom.org/cellular-infrastructure/osmo-gsm-manuals
+ </ulink>
+ </para>
+</legalnotice>
diff --git a/doc/manuals/osmopcap-usermanual.adoc b/doc/manuals/osmopcap-usermanual.adoc
new file mode 100644
index 0000000..63daf6c
--- /dev/null
+++ b/doc/manuals/osmopcap-usermanual.adoc
@@ -0,0 +1,32 @@
+:gfdl-enabled:
+:program-name: OsmoPCAP
+
+OsmoPCAP User Manual
+====================
+Harald Welte <hwelte@sysmocom.de>
+
+
+include::./common/chapters/preface.adoc[]
+
+include::{srcdir}/chapters/overview.adoc[]
+
+include::{srcdir}/chapters/client.adoc[]
+
+include::{srcdir}/chapters/server.adoc[]
+
+
+include::./common/chapters/counters-overview.adoc[]
+
+
+
+include::./common/chapters/vty.adoc[]
+
+include::./common/chapters/logging.adoc[]
+
+include::./common/chapters/port_numbers.adoc[]
+
+include::./common/chapters/bibliography.adoc[]
+
+include::./common/chapters/glossary.adoc[]
+
+include::./common/chapters/gfdl.adoc[]
diff --git a/doc/manuals/vty/Makefile.vty-reference.inc b/doc/manuals/vty/Makefile.vty-reference.inc
new file mode 100644
index 0000000..ea8c68e
--- /dev/null
+++ b/doc/manuals/vty/Makefile.vty-reference.inc
@@ -0,0 +1,37 @@
+DOCBOOKS = $(foreach v,$(VARIANTS),vty/osmo-pcap-$(v)-vty-reference.xml)
+DOCBOOKS_DEPS = $(DOCBOOKS) $(addsuffix .inc,$(DOCBOOKS))
+INC_DIR = $(abspath $(builddir)/vty)
+
+include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.docbook.inc
+
+CLEAN_FILES += $(DOCBOOKS_DEPS)
+CLEAN_FILES += $(addsuffix .inc.gen,$(DOCBOOKS))
+CLEAN_FILES += $(addsuffix .inc.merged,$(DOCBOOKS))
+
+$(INC_DIR):
+ mkdir -p $@
+
+vty/osmo-pcap-%-vty-reference.xml: $(top_builddir)/src/osmo-pcap-% $(INC_DIR)
+ sed -e "s|@@GENERATED@@|$@.inc|" \
+ -e "s|@@VARIANT@@|$(notdir $<)|" \
+ -e "s|@@REV_NUMBER@@|$(VERSION)|" \
+ -e "s|@@REV_DATE@@|$(shell date +"%dth %B %Y")|" \
+ -e "s|@@CR_YEAR@@|$(shell date +"%Y")|" \
+ $(srcdir)/vty/osmo-pcap-vty-reference.xml > $@
+
+vty/osmo-pcap-%-vty-reference.xml.inc: $(top_builddir)/src/osmo-pcap-% \
+ $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
+ $(OSMO_GSM_MANUALS_DIR)/common/chapters/vty.xml \
+ $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl \
+ $(srcdir)/vty/*.xml $(INC_DIR)
+ # a) Invoke osmo-pcap-% to generate the list of commands first
+ $< --vty-ref-mode default --vty-ref-xml > "$@.gen"
+ # ... filter garbage potentially printed by libraries to stdout
+ sed -i '/^<vtydoc/,$$!d' "$@.gen"
+ # b) Merge the result of a) with global and local additions
+ $(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh \
+ $(realpath $(OSMO_GSM_MANUALS_DIR)/merge_doc.xsl) "$@.gen" \
+ $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
+ $(srcdir)/vty/vty_additions.xml > "$@.merged"
+ # c) Convert the result of b) into a valid docbook
+ xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl "$@.merged" > $@
diff --git a/doc/manuals/vty/osmo-pcap-vty-reference.xml b/doc/manuals/vty/osmo-pcap-vty-reference.xml
new file mode 100644
index 0000000..f4955dc
--- /dev/null
+++ b/doc/manuals/vty/osmo-pcap-vty-reference.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML 5.0//EN"
+"http://docbook.org/xml/5.0/dtd/docbook.dtd" [
+<!ENTITY chapter-vty SYSTEM "./common/chapters/vty.xml" >
+<!ENTITY sections-vty SYSTEM "@@GENERATED@@" >
+]>
+
+<book>
+ <info>
+ <revhistory>
+ <revision>
+ <revnumber>v1</revnumber>
+ <date>@@REV_DATE@@</date>
+ <authorinitials>s.f.m.c.</authorinitials>
+ <revremark>Automatic build (@@REV_NUMBER@@)</revremark>
+ </revision>
+ </revhistory>
+
+ <title>OsmoPCAP VTY Reference</title>
+ <subtitle>@@VARIANT@@</subtitle>
+
+ <copyright>
+ <year>@@CR_YEAR@@</year>
+ </copyright>
+
+ <legalnotice>
+ <para>This work is copyright by <orgname>sysmocom - s.f.m.c. GmbH</orgname>. All rights reserved.
+ </para>
+ </legalnotice>
+ </info>
+
+ <!-- Main chapters-->
+ &chapter-vty;
+</book>
diff --git a/doc/manuals/vty/vty_additions.xml b/doc/manuals/vty/vty_additions.xml
new file mode 100644
index 0000000..a4c675e
--- /dev/null
+++ b/doc/manuals/vty/vty_additions.xml
@@ -0,0 +1,2 @@
+<vtydoc xmlns='urn:osmocom:xml:libosmocore:vty:doc:1.0'>
+</vtydoc>
diff --git a/include/osmo-pcap/common.h b/include/osmo-pcap/common.h
index 79080a2..7ac5bb0 100644
--- a/include/osmo-pcap/common.h
+++ b/include/osmo-pcap/common.h
@@ -32,10 +32,10 @@
/* support old versions of libosmocore */
#ifndef OSMO_VTY_PORT_PCAP_CLIENT
-#define OSMO_VTY_PORT_PCAP_CLIENT 4237
+#define OSMO_VTY_PORT_PCAP_CLIENT 4227
#endif
#ifndef OSMO_VTY_PORT_PCAP_SERVER
-#define OSMO_VTY_PORT_PCAP_SERVER 4238
+#define OSMO_VTY_PORT_PCAP_SERVER 4228
#endif
enum {
diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h
index 70be8db..5bc203a 100644
--- a/include/osmo-pcap/osmo_pcap_client.h
+++ b/include/osmo-pcap/osmo_pcap_client.h
@@ -32,6 +32,8 @@
struct rate_ctr_group;
+#define WQUEUE_MAXLEN_DEFAULT 1000
+
enum {
CLIENT_CTR_CONNECT,
CLIENT_CTR_BYTES,
@@ -107,7 +109,7 @@ struct osmo_pcap_client {
extern struct osmo_pcap_client *pcap_client;
struct osmo_pcap_client *osmo_pcap_client_alloc(void *tall_ctx);
-int vty_client_init(struct osmo_pcap_client *);
+int vty_client_init(void);
int osmo_client_capture(struct osmo_pcap_client *client, const char *device);
int osmo_client_filter(struct osmo_pcap_client *client, const char *filter);
diff --git a/include/osmo-pcap/osmo_pcap_server.h b/include/osmo-pcap/osmo_pcap_server.h
index a983ec5..6d2afcf 100644
--- a/include/osmo-pcap/osmo_pcap_server.h
+++ b/include/osmo-pcap/osmo_pcap_server.h
@@ -129,6 +129,7 @@ struct osmo_pcap_server {
bool dh_params_allocated;
char *base_path;
+ mode_t permission_mask;
off_t max_size;
int max_snaplen;
@@ -144,7 +145,7 @@ int osmo_pcap_server_listen(struct osmo_pcap_server *server);
struct osmo_pcap_conn *osmo_pcap_server_find(struct osmo_pcap_server *ser,
const char *name);
void osmo_pcap_server_delete(struct osmo_pcap_conn *conn);
-void vty_server_init(struct osmo_pcap_server *server);
+void vty_server_init(void);
void osmo_pcap_server_close_trace(struct osmo_pcap_conn *conn);
void osmo_pcap_server_close_conn(struct osmo_pcap_conn *conn);
diff --git a/osmoappdesc.py b/osmoappdesc.py
index 331e6a9..36fef63 100644
--- a/osmoappdesc.py
+++ b/osmoappdesc.py
@@ -22,8 +22,8 @@ app_configs = {
}
apps = [
- (4238, "src/osmo-pcap-server", "OsmoPCAPServer", "osmo-pcap-server"),
- (4237, "src/osmo-pcap-client", "OsmoPCAPClient", "osmo-pcap-client"),
+ (4228, "src/osmo-pcap-server", "OsmoPCAPServer", "osmo-pcap-server"),
+ (4227, "src/osmo-pcap-client", "OsmoPCAPClient", "osmo-pcap-client"),
]
vty_command = ["src/osmo-pcap-server", "-c", "doc/examples/osmo-pcap-server/osmo-pcap-server.cfg"]
diff --git a/src/Makefile.am b/src/Makefile.am
index 17ed4e3..6b887d3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,5 @@
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(PCAP_CFLAGS) $(LIBGNUTLS_CFLAGS)
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(PCAP_CFLAGS) $(LIBGNUTLS_CFLAGS)
bin_PROGRAMS = osmo-pcap-client osmo-pcap-server
diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c
index 025e3a4..4bb4b4e 100644
--- a/src/osmo_client_core.c
+++ b/src/osmo_client_core.c
@@ -161,7 +161,7 @@ static int pcap_read_cb(struct osmo_fd *fd, unsigned int what)
data = pcap_next(client->handle, &hdr);
if (!data) {
- rate_ctr_inc(&client->ctrg->ctr[CLIENT_CTR_PERR]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(client->ctrg, CLIENT_CTR_PERR));
return -1;
}
@@ -190,14 +190,14 @@ static void add_psbl_wrapped_ctr(struct osmo_pcap_client *client,
* Only issue is we don't know sizeof(u_int)
*/
if (*old_val > new_val) {
- rate_ctr_add(&client->ctrg->ctr[ctr], P_CAP_UINT_MAX() - *old_val);
- rate_ctr_add(&client->ctrg->ctr[ctr], new_val);
+ rate_ctr_add(rate_ctr_group_get_ctr(client->ctrg, ctr), P_CAP_UINT_MAX() - *old_val);
+ rate_ctr_add(rate_ctr_group_get_ctr(client->ctrg, ctr), new_val);
*old_val = new_val;
return;
}
/* Just increment it */
- rate_ctr_add(&client->ctrg->ctr[ctr], new_val - *old_val);
+ rate_ctr_add(rate_ctr_group_get_ctr(client->ctrg, ctr), new_val - *old_val);
*old_val = new_val;
}
@@ -215,7 +215,7 @@ static void pcap_check_stats_cb(void *_client)
if (rc != 0) {
LOGP(DCLIENT, LOGL_ERROR, "Failed to query pcap stats: %s\n",
pcap_geterr(client->handle));
- rate_ctr_inc(&client->ctrg->ctr[CLIENT_CTR_PERR]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(client->ctrg, CLIENT_CTR_PERR));
return;
}
@@ -341,7 +341,7 @@ void osmo_client_conn_init(struct osmo_pcap_client_conn *conn,
{
conn->client = client;
conn->tls_verify = true;
- osmo_wqueue_init(&conn->wqueue, 10);
+ osmo_wqueue_init(&conn->wqueue, WQUEUE_MAXLEN_DEFAULT);
conn->wqueue.bfd.fd = -1;
}
diff --git a/src/osmo_client_main.c b/src/osmo_client_main.c
index c7d68d4..818a2f1 100644
--- a/src/osmo_client_main.c
+++ b/src/osmo_client_main.c
@@ -33,6 +33,7 @@
#include <osmocom/vty/logging.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/stats.h>
+#include <osmocom/vty/misc.h>
#include <pcap.h>
#include <signal.h>
@@ -50,8 +51,6 @@ static int daemonize = 0;
void *tall_cli_ctx;
struct osmo_pcap_client *pcap_client;
-extern void *tall_msgb_ctx;
-extern void *tall_ctr_ctx;
static const struct rate_ctr_desc pcap_client_ctr_desc[] = {
@@ -80,7 +79,6 @@ static struct vty_app_info vty_info = {
.name = "OsmoPCAPClient",
.version = PACKAGE_VERSION,
.go_parent_cb = osmopcap_go_parent,
- .is_config_node = osmopcap_is_config_node,
};
static void print_usage()
@@ -93,25 +91,58 @@ static void print_help()
printf(" Some useful help...\n");
printf(" -h --help this text\n");
printf(" -D --daemonize Fork the process into a background daemon\n");
+ printf(" -V --version Print the version number\n");
printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM enable debugging\n");
printf(" -s --disable-color\n");
printf(" -T --timestamp. Print a timestamp in the debug output.\n");
printf(" -e --log-level number. Set a global loglevel.\n");
printf(" -c --config-file filename The config file to use.\n");
+
+ printf("\nVTY reference generation:\n");
+ printf(" --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n");
+ printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
+}
+
+static void handle_long_options(const char *prog_name, const int long_option)
+{
+ static int vty_ref_mode = VTY_REF_GEN_MODE_DEFAULT;
+ switch (long_option) {
+ case 1:
+ vty_ref_mode = get_string_value(vty_ref_gen_mode_names, optarg);
+ if (vty_ref_mode < 0) {
+ fprintf(stderr, "%s: Unknown VTY reference generation "
+ "mode '%s'\n", prog_name, optarg);
+ exit(2);
+ }
+ break;
+ case 2:
+ fprintf(stderr, "Generating the VTY reference in mode '%s' (%s)\n",
+ get_value_string(vty_ref_gen_mode_names, vty_ref_mode),
+ get_value_string(vty_ref_gen_mode_desc, vty_ref_mode));
+ vty_dump_xml_ref_mode(stdout, (enum vty_ref_gen_mode) vty_ref_mode);
+ exit(0);
+ default:
+ fprintf(stderr, "%s: error parsing cmdline options\n", prog_name);
+ exit(2);
+ }
}
static void handle_options(int argc, char **argv)
{
while (1) {
int option_index = 0, c;
+ static int long_option = 0;
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"daemonize", 0, 0, 'D'},
{"debug", 1, 0, 'd'},
+ {"version", 0, 0, 'V'},
{"disable-color", 0, 0, 's'},
{"timestamp", 0, 0, 'T'},
{"log-level", 1, 0, 'e'},
{"config-file", 1, 0, 'c'},
+ {"vty-ref-mode", 1, &long_option, 1},
+ {"vty-ref-xml", 0, &long_option, 2},
{0, 0, 0, 0}
};
@@ -125,12 +156,19 @@ static void handle_options(int argc, char **argv)
print_usage();
print_help();
exit(0);
+ case 0:
+ handle_long_options(argv[0], long_option);
+ break;
case 'D':
daemonize = 1;
break;
case 'd':
log_parse_category_mask(osmo_stderr_target, optarg);
break;
+ case 'V':
+ print_version(1);
+ exit(0);
+ break;
case 's':
log_set_use_color(osmo_stderr_target, 0);
break;
@@ -182,8 +220,7 @@ static void signal_handler(int signum)
static void talloc_init_ctx()
{
tall_cli_ctx = talloc_named_const(NULL, 0, "client");
- tall_msgb_ctx = talloc_named_const(tall_cli_ctx, 0, "msgb");
- tall_ctr_ctx = talloc_named_const(tall_cli_ctx, 0, "counter");
+ msgb_talloc_ctx_init(tall_cli_ctx, 0);
}
int main(int argc, char **argv)
@@ -194,9 +231,12 @@ int main(int argc, char **argv)
osmo_init_logging2(tall_cli_ctx, &log_info);
vty_info.copyright = osmopcap_copyright;
+ vty_info.tall_ctx = tall_cli_ctx;
vty_init(&vty_info);
logging_vty_add_cmds();
osmo_stats_vty_add_cmds();
+ osmo_talloc_vty_add_cmds();
+ vty_client_init();
/* parse options */
handle_options(argc, argv);
@@ -215,18 +255,11 @@ int main(int argc, char **argv)
osmo_tls_init();
- rc = telnet_init(tall_cli_ctx, NULL, OSMO_VTY_PORT_PCAP_CLIENT);
- if (rc < 0) {
- LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n");
- exit(1);
- }
-
pcap_client = osmo_pcap_client_alloc(tall_cli_ctx);
if (!pcap_client) {
LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate osmo_pcap_client.\n");
exit(1);
}
- vty_client_init(pcap_client);
/* initialize the queue */
INIT_LLIST_HEAD(&pcap_client->conns);
@@ -246,6 +279,13 @@ int main(int argc, char **argv)
exit(1);
}
+ rc = telnet_init_default(tall_cli_ctx, NULL, OSMO_VTY_PORT_PCAP_CLIENT);
+ if (rc < 0) {
+ LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n");
+ exit(1);
+ }
+
+
/* attempt to connect to the remote */
if (pcap_client->conn.srv_ip && pcap_client->conn.srv_port > 0)
osmo_client_connect(&pcap_client->conn);
diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c
index 32d450f..9a430ab 100644
--- a/src/osmo_client_network.c
+++ b/src/osmo_client_network.c
@@ -58,9 +58,10 @@ static void lost_connection(struct osmo_pcap_client_conn *conn)
static void write_data(struct osmo_pcap_client_conn *conn, struct msgb *msg)
{
- if (osmo_wqueue_enqueue(&conn->wqueue, msg) != 0) {
- LOGP(DCLIENT, LOGL_ERROR, "Failed to enqueue conn=%s\n", conn->name);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_QERR]);
+ if (osmo_wqueue_enqueue_quiet(&conn->wqueue, msg) != 0) {
+ LOGP(DCLIENT, LOGL_ERROR, "Failed to enqueue conn=%s (capacity: %u/%u)\n",
+ conn->name, conn->wqueue.current_length, conn->wqueue.max_length);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_QERR));
msgb_free(msg);
return;
}
@@ -92,7 +93,7 @@ static int write_cb(struct osmo_fd *fd, struct msgb *msg)
struct osmo_pcap_client_conn *conn = fd->data;
LOGP(DCLIENT, LOGL_ERROR, "Lost connection on write to %s %s:%d.\n",
conn->name, conn->srv_ip, conn->srv_port);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_WERR]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_WERR));
lost_connection(conn);
return -1;
}
@@ -173,13 +174,13 @@ void osmo_client_send_data(struct osmo_pcap_client_conn *conn,
LOGP(DCLIENT, LOGL_ERROR,
"Recording truncated packet, len %zu > snaplen %zu\n",
(size_t) in_hdr->len, (size_t) in_hdr->caplen);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_2BIG]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_2BIG));
}
msg = msgb_alloc(in_hdr->caplen + sizeof(*om_hdr) + sizeof(*hdr), "data-data");
if (!msg) {
LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate.\n");
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_NOMEM]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_NOMEM));
return;
}
@@ -199,8 +200,8 @@ void osmo_client_send_data(struct osmo_pcap_client_conn *conn,
memcpy(msg->l3h, data, in_hdr->caplen);
om_hdr->len = htons(msgb_l2len(msg));
- rate_ctr_add(&conn->client->ctrg->ctr[CLIENT_CTR_BYTES], hdr->caplen);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_PKTS]);
+ rate_ctr_add(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_BYTES), hdr->caplen);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_PKTS));
break;
case PROTOCOL_IPIP:
offset = get_iphdr_offset(pcap_datalink(conn->client->handle));
@@ -293,10 +294,8 @@ void osmo_client_connect(struct osmo_pcap_client_conn *conn)
break;
}
- osmo_fd_setup(&conn->wqueue.bfd, -1, when, conn_cb, conn, 0);
- rc = osmo_sock_init2_ofd(&conn->wqueue.bfd, AF_INET, sock_type, sock_proto,
- conn->source_ip, 0, conn->srv_ip, srv_port,
- OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK);
+ rc = osmo_sock_init2(AF_INET, sock_type, sock_proto, conn->source_ip, 0, conn->srv_ip, srv_port,
+ OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK);
if (rc < 0) {
LOGP(DCLIENT, LOGL_ERROR,
"Failed to connect conn=%s to %s:%d\n",
@@ -304,8 +303,10 @@ void osmo_client_connect(struct osmo_pcap_client_conn *conn)
lost_connection(conn);
return;
}
+ osmo_fd_setup(&conn->wqueue.bfd, rc, when, conn_cb, conn, 0);
+ osmo_fd_register(&conn->wqueue.bfd);
- rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_CONNECT]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->client->ctrg, CLIENT_CTR_CONNECT));
}
void osmo_client_reconnect(struct osmo_pcap_client_conn *conn)
diff --git a/src/osmo_client_vty.c b/src/osmo_client_vty.c
index 30158c5..8e21d67 100644
--- a/src/osmo_client_vty.c
+++ b/src/osmo_client_vty.c
@@ -46,13 +46,13 @@ static struct osmo_pcap_client_conn *get_conn(struct vty *vty)
static struct cmd_node client_node = {
CLIENT_NODE,
- "%s(client)#",
+ "%s(client)# ",
1,
};
static struct cmd_node server_node = {
CLIENT_SERVER_NODE,
- "%s(server)#",
+ "%s(server)# ",
1,
};
@@ -104,6 +104,10 @@ static void write_client_conn_data(
if (conn->protocol != PROTOCOL_OSMOPCAP)
vty_out(vty, "%s protocol %s%s", indent,
get_value_string(osmopcap_protocol_names, conn->protocol), VTY_NEWLINE);
+
+ if (conn->wqueue.max_length != WQUEUE_MAXLEN_DEFAULT)
+ vty_out(vty, "%s wqueue max-length %u%s", indent,
+ conn->wqueue.max_length, VTY_NEWLINE);
}
static int config_write_server(struct vty *vty)
@@ -518,8 +522,20 @@ DEFUN(cfg_client_protocol,
return CMD_SUCCESS;
}
+DEFUN(cfg_wqueue_maxlength,
+ cfg_wqueue_maxlength_cmd,
+ "wqueue max-length <1-4294967295>",
+ "Configure the write-queue used for transfer\n"
+ "Configure the maximum amount of packets to be stored in the write-queue\n"
+ "Maximum amount of packets before dropping starts\n")
+{
+ struct osmo_pcap_client_conn *conn = get_conn(vty);
+
+ conn->wqueue.max_length = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
-int vty_client_init(struct osmo_pcap_client *pcap)
+int vty_client_init(void)
{
install_element(CONFIG_NODE, &cfg_client_cmd);
install_node(&client_node, config_write_client);
@@ -535,6 +551,7 @@ int vty_client_init(struct osmo_pcap_client *pcap)
install_element(CLIENT_NODE, &cfg_server_port_cmd);
install_element(CLIENT_NODE, &cfg_source_ip_cmd);
install_element(CLIENT_NODE, &cfg_protocol_cmd);
+ install_element(CLIENT_NODE, &cfg_wqueue_maxlength_cmd);
install_element(CLIENT_NODE, &cfg_enable_tls_cmd);
install_element(CLIENT_NODE, &cfg_disable_tls_cmd);
diff --git a/src/osmo_common.c b/src/osmo_common.c
index 6352097..b90d339 100644
--- a/src/osmo_common.c
+++ b/src/osmo_common.c
@@ -62,8 +62,8 @@ const struct log_info log_info = {
.num_cat = ARRAY_SIZE(default_categories),
};
-const char *osmopcap_copyright =
- "Copyright (C) 2011 Holger Freyther\r\n"
+const char *osmopcap_copyright =
+ "Copyright (C) 2011-2017 Holger Freyther and contributors\r\n"
"License AGPLv3+: GNU AGPL version 3 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n"
"This is free software: you are free to change and redistribute it.\r\n"
"There is NO WARRANTY, to the extent permitted by law.\r\n";
@@ -86,15 +86,5 @@ int osmopcap_go_parent(struct vty *vty)
break;
}
- return vty->node;
-}
-
-int osmopcap_is_config_node(struct vty *vty, int node)
-{
- switch (node) {
- case CONFIG_NODE:
- return 0;
- default:
- return 1;
- }
+ return vty->node;
}
diff --git a/src/osmo_server_main.c b/src/osmo_server_main.c
index 51441a7..4633888 100644
--- a/src/osmo_server_main.c
+++ b/src/osmo_server_main.c
@@ -34,6 +34,7 @@
#include <osmocom/vty/logging.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/stats.h>
+#include <osmocom/vty/misc.h>
#include <pcap.h>
#include <signal.h>
@@ -51,8 +52,6 @@ static int daemonize = 0;
void *tall_srv_ctx;
struct osmo_pcap_server *pcap_server;
-extern void *tall_msgb_ctx;
-extern void *tall_ctr_ctx;
static const struct rate_ctr_desc pcap_peer_ctr_desc[] = {
@@ -90,7 +89,6 @@ static struct vty_app_info vty_info = {
.name = "OsmoPCAPServer",
.version = PACKAGE_VERSION,
.go_parent_cb = osmopcap_go_parent,
- .is_config_node = osmopcap_is_config_node,
};
static void print_usage()
@@ -103,25 +101,58 @@ static void print_help()
printf(" Some useful help...\n");
printf(" -h --help this text\n");
printf(" -D --daemonize Fork the process into a background daemon\n");
+ printf(" -V --version Print the version number\n");
printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM enable debugging\n");
printf(" -s --disable-color\n");
printf(" -T --timestamp. Print a timestamp in the debug output.\n");
printf(" -e --log-level number. Set a global loglevel.\n");
printf(" -c --config-file filename The config file to use.\n");
+
+ printf("\nVTY reference generation:\n");
+ printf(" --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n");
+ printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
+}
+
+static void handle_long_options(const char *prog_name, const int long_option)
+{
+ static int vty_ref_mode = VTY_REF_GEN_MODE_DEFAULT;
+ switch (long_option) {
+ case 1:
+ vty_ref_mode = get_string_value(vty_ref_gen_mode_names, optarg);
+ if (vty_ref_mode < 0) {
+ fprintf(stderr, "%s: Unknown VTY reference generation "
+ "mode '%s'\n", prog_name, optarg);
+ exit(2);
+ }
+ break;
+ case 2:
+ fprintf(stderr, "Generating the VTY reference in mode '%s' (%s)\n",
+ get_value_string(vty_ref_gen_mode_names, vty_ref_mode),
+ get_value_string(vty_ref_gen_mode_desc, vty_ref_mode));
+ vty_dump_xml_ref_mode(stdout, (enum vty_ref_gen_mode) vty_ref_mode);
+ exit(0);
+ default:
+ fprintf(stderr, "%s: error parsing cmdline options\n", prog_name);
+ exit(2);
+ }
}
static void handle_options(int argc, char **argv)
{
while (1) {
int option_index = 0, c;
+ static int long_option = 0;
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"daemonize", 0, 0, 'D'},
{"debug", 1, 0, 'd'},
+ {"version", 0, 0, 'V'},
{"disable-color", 0, 0, 's'},
{"timestamp", 0, 0, 'T'},
{"log-level", 1, 0, 'e'},
{"config-file", 1, 0, 'c'},
+ {"vty-ref-mode", 1, &long_option, 1},
+ {"vty-ref-xml", 0, &long_option, 2},
{0, 0, 0, 0}
};
@@ -135,12 +166,18 @@ static void handle_options(int argc, char **argv)
print_usage();
print_help();
exit(0);
+ case 0:
+ handle_long_options(argv[0], long_option);
+ break;
case 'D':
daemonize = 1;
break;
case 'd':
log_parse_category_mask(osmo_stderr_target, optarg);
break;
+ case 'V':
+ print_version(1);
+ exit(0);
case 's':
log_set_use_color(osmo_stderr_target, 0);
break;
@@ -195,8 +232,7 @@ static void signal_handler(int signum)
static void talloc_init_ctx()
{
tall_srv_ctx = talloc_named_const(NULL, 0, "server");
- tall_msgb_ctx = talloc_named_const(tall_srv_ctx, 0, "msgb");
- tall_ctr_ctx = talloc_named_const(tall_srv_ctx, 0, "counter");
+ msgb_talloc_ctx_init(tall_srv_ctx, 0);
}
int main(int argc, char **argv)
@@ -207,9 +243,12 @@ int main(int argc, char **argv)
osmo_init_logging2(tall_srv_ctx, &log_info);
vty_info.copyright = osmopcap_copyright;
+ vty_info.tall_ctx = tall_srv_ctx;
vty_init(&vty_info);
logging_vty_add_cmds();
osmo_stats_vty_add_cmds();
+ osmo_talloc_vty_add_cmds();
+ vty_server_init();
/* parse options */
handle_options(argc, argv);
@@ -228,12 +267,6 @@ int main(int argc, char **argv)
osmo_tls_init();
- rc = telnet_init(tall_srv_ctx, NULL, OSMO_VTY_PORT_PCAP_SERVER);
- if (rc < 0) {
- LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n");
- exit(1);
- }
-
pcap_server = talloc_zero(tall_srv_ctx, struct osmo_pcap_server);
if (!pcap_server) {
LOGP(DSERVER, LOGL_ERROR, "Failed to allocate osmo_pcap_server.\n");
@@ -247,9 +280,9 @@ int main(int argc, char **argv)
INIT_LLIST_HEAD(&pcap_server->conn);
pcap_server->base_path = talloc_strdup(pcap_server, "./");
+ pcap_server->permission_mask = 0440;
pcap_server->max_size = 1073741824;
pcap_server->max_snaplen = DEFAULT_SNAPLEN;
- vty_server_init(pcap_server);
if (vty_read_config_file(config_file, NULL) < 0) {
LOGP(DSERVER, LOGL_ERROR,
@@ -257,6 +290,12 @@ int main(int argc, char **argv)
exit(1);
}
+ rc = telnet_init_default(tall_srv_ctx, NULL, OSMO_VTY_PORT_PCAP_SERVER);
+ if (rc < 0) {
+ LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n");
+ exit(1);
+ }
+
osmo_tls_server_init(pcap_server);
/* attempt to connect to the remote */
diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c
index 164b161..b566bd2 100644
--- a/src/osmo_server_network.c
+++ b/src/osmo_server_network.c
@@ -120,8 +120,8 @@ void osmo_pcap_server_close_trace(struct osmo_pcap_conn *conn)
if (conn->curr_filename) {
client_event(conn, "closingtracefile", conn->curr_filename);
- rate_ctr_inc(&conn->ctrg->ctr[PEER_CTR_PROTATE]);
- rate_ctr_inc(&conn->server->ctrg->ctr[SERVER_CTR_PROTATE]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->ctrg, PEER_CTR_PROTATE));
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->server->ctrg, SERVER_CTR_PROTATE));
talloc_free(conn->curr_filename);
conn->curr_filename = NULL;
}
@@ -130,10 +130,10 @@ void osmo_pcap_server_close_trace(struct osmo_pcap_conn *conn)
static void close_connection(struct osmo_pcap_conn *conn)
{
if (conn->rem_wq.bfd.fd >= 0) {
+ osmo_fd_unregister(&conn->rem_wq.bfd);
close(conn->rem_wq.bfd.fd);
conn->rem_wq.bfd.fd = -1;
osmo_tls_release(&conn->tls_session);
- osmo_fd_unregister(&conn->rem_wq.bfd);
}
osmo_pcap_server_close_trace(conn);
@@ -171,7 +171,7 @@ static void restart_pcap(struct osmo_pcap_conn *conn)
return;
}
- conn->local_fd = creat(conn->curr_filename, 0440);
+ conn->local_fd = creat(conn->curr_filename, conn->server->permission_mask);
if (conn->local_fd < 0) {
LOGP(DSERVER, LOGL_ERROR, "Failed to file: '%s'\n", conn->curr_filename);
return;
@@ -422,12 +422,12 @@ static int read_cb_data(struct osmo_pcap_conn *conn)
conn->pend = sizeof(*conn->data);
/* count the full packet we got */
- rate_ctr_inc(&conn->ctrg->ctr[PEER_CTR_PKTS]);
- rate_ctr_inc(&conn->server->ctrg->ctr[SERVER_CTR_PKTS]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->ctrg, PEER_CTR_PKTS));
+ rate_ctr_inc(rate_ctr_group_get_ctr(conn->server->ctrg, SERVER_CTR_PKTS));
/* count the bytes of it */
- rate_ctr_add(&conn->ctrg->ctr[PEER_CTR_BYTES], conn->data->len);
- rate_ctr_add(&conn->server->ctrg->ctr[SERVER_CTR_BYTES], conn->data->len);
+ rate_ctr_add(rate_ctr_group_get_ctr(conn->ctrg, PEER_CTR_BYTES), conn->data->len);
+ rate_ctr_add(rate_ctr_group_get_ctr(conn->server->ctrg, SERVER_CTR_BYTES), conn->data->len);
switch (conn->data->type) {
case PKT_LINK_HDR:
@@ -520,7 +520,7 @@ static void new_connection(struct osmo_pcap_server *server,
return;
}
- rate_ctr_inc(&client->ctrg->ctr[PEER_CTR_CONNECT]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(client->ctrg, PEER_CTR_CONNECT));
client->state = STATE_INITIAL;
client->pend = sizeof(*client->data);
@@ -565,7 +565,7 @@ static int accept_cb(struct osmo_fd *fd, unsigned int when)
server = fd->data;
/* count any accept to see no clients */
- rate_ctr_inc(&server->ctrg->ctr[SERVER_CTR_CONNECT]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(server->ctrg, SERVER_CTR_CONNECT));
llist_for_each_entry(conn, &server->conn, entry) {
if (conn->remote_addr.s_addr == addr.sin_addr.s_addr) {
@@ -577,7 +577,7 @@ static int accept_cb(struct osmo_fd *fd, unsigned int when)
}
}
- rate_ctr_inc(&server->ctrg->ctr[SERVER_CTR_NOCLIENT]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(server->ctrg, SERVER_CTR_NOCLIENT));
/*
* TODO: In the future start with a tls handshake and see if we know
diff --git a/src/osmo_server_vty.c b/src/osmo_server_vty.c
index e9b54b1..796aed8 100644
--- a/src/osmo_server_vty.c
+++ b/src/osmo_server_vty.c
@@ -88,6 +88,7 @@ static int config_write_server(struct vty *vty)
if (pcap_server->base_path)
vty_out(vty, " base-path %s%s", pcap_server->base_path, VTY_NEWLINE);
+ vty_out(vty, " file-permission-mask 0%o%s", pcap_server->permission_mask, VTY_NEWLINE);
if (pcap_server->addr)
vty_out(vty, " server ip %s%s", pcap_server->addr, VTY_NEWLINE);
if (pcap_server->port > 0)
@@ -132,6 +133,46 @@ DEFUN(cfg_server_base,
return CMD_SUCCESS;
}
+DEFUN(cfg_server_file_permission_mask,
+ cfg_server_file_permission_mask_cmd,
+ "file-permission-mask MODE",
+ "Permission mask to use when creating pcap files\n"
+ "The file permission mask, in octal format (default: 0440)\n")
+{
+ unsigned long long val;
+ char *endptr;
+
+ errno = 0;
+ val = strtoul(argv[0], &endptr, 8);
+
+ switch (errno) {
+ case 0:
+ break;
+ case ERANGE:
+ case EINVAL:
+ default:
+ goto ret_invalid;
+ }
+ if (!endptr || *endptr) {
+ /* No chars were converted */
+ if (endptr == argv[0])
+ goto ret_invalid;
+ /* Or there are surplus chars after the converted number */
+ goto ret_invalid;
+ }
+
+ /* 'man mode_t': "According to POSIX, it shall be an integer type." */
+ if (val > INT_MAX)
+ goto ret_invalid;
+
+ pcap_server->permission_mask = val;
+ return CMD_SUCCESS;
+
+ret_invalid:
+ vty_out(vty, "%% File permission mask out of range: '%s'%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+}
+
DEFUN(cfg_server_ip,
cfg_server_ip_cmd,
"server ip A.B.C.D",
@@ -513,12 +554,13 @@ DEFUN(cfg_tls_dh_generate,
return CMD_SUCCESS;
}
-void vty_server_init(struct osmo_pcap_server *server)
+void vty_server_init(void)
{
install_element(CONFIG_NODE, &cfg_server_cmd);
install_node(&server_node, config_write_server);
install_element(SERVER_NODE, &cfg_server_base_cmd);
+ install_element(SERVER_NODE, &cfg_server_file_permission_mask_cmd);
install_element(SERVER_NODE, &cfg_server_ip_cmd);
install_element(SERVER_NODE, &cfg_server_port_cmd);
install_element(SERVER_NODE, &cfg_server_max_size_cmd);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 720d631..5084704 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,11 +21,12 @@ DISTCLEANFILES = atconfig
TESTSUITE = $(srcdir)/testsuite
if ENABLE_EXT_TESTS
-python-tests: $(BUILT_SOURCES)
+python-tests: $(top_builddir)/src/osmo-pcap-server \
+ $(top_builddir)/src/osmo-pcap-client
osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
else
-python-tests: $(BUILT_SOURCES)
+python-tests:
echo "Not running python-based tests (determined at configure-time)"
endif