[PATCH] meta-telephony[201705]: Add recipe for osmo-pcap, both server and client

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Aug 15 19:07:22 UTC 2017


Review at  https://gerrit.osmocom.org/3534

Add recipe for osmo-pcap, both server and client

Change-Id: I5bb85b118029d1559a958803184690a9d0f23e4a
---
A recipes-osmocom/osmo-pcap/files/0001-Makefile-Allow-cross-compilation-environment-to-spec.patch
A recipes-osmocom/osmo-pcap/files/0001-Rename-osmo_pcap_-client_server-executables-to-osmo-.patch
A recipes-osmocom/osmo-pcap/files/0001-sock_src_init-Don-t-freeaddrinfo-undefined-src_resul.patch
A recipes-osmocom/osmo-pcap/files/0002-Use-TCP-port-numbers-for-VTY-that-don-t-overlap-with.patch
A recipes-osmocom/osmo-pcap/files/osmo-pcap-client.service
A recipes-osmocom/osmo-pcap/files/osmo-pcap-server.service
A recipes-osmocom/osmo-pcap/osmo-pcap_git.bb
7 files changed, 252 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/meta-telephony refs/changes/34/3534/1

diff --git a/recipes-osmocom/osmo-pcap/files/0001-Makefile-Allow-cross-compilation-environment-to-spec.patch b/recipes-osmocom/osmo-pcap/files/0001-Makefile-Allow-cross-compilation-environment-to-spec.patch
new file mode 100644
index 0000000..8952773
--- /dev/null
+++ b/recipes-osmocom/osmo-pcap/files/0001-Makefile-Allow-cross-compilation-environment-to-spec.patch
@@ -0,0 +1,25 @@
+From d6bd89581ac104a56441f63ca4a8f2139917f9f6 Mon Sep 17 00:00:00 2001
+From: Harald Welte <laforge at gnumonks.org>
+Date: Mon, 10 Jul 2017 13:58:58 +0200
+Subject: [PATCH] Makefile: Allow cross-compilation environment to specify CC
+
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index b670978..9af3c99 100644
+--- a/Makefile
++++ b/Makefile
+@@ -4,7 +4,7 @@ N2N_OSNAME=$(shell uname -p)
+ 
+ ########
+ 
+-CC=gcc
++CC?=gcc
+ DEBUG?=-g3
+ #OPTIMIZATION?=-O2
+ WARN?=-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs
+-- 
+2.11.0
+
diff --git a/recipes-osmocom/osmo-pcap/files/0001-Rename-osmo_pcap_-client_server-executables-to-osmo-.patch b/recipes-osmocom/osmo-pcap/files/0001-Rename-osmo_pcap_-client_server-executables-to-osmo-.patch
new file mode 100644
index 0000000..64d7353
--- /dev/null
+++ b/recipes-osmocom/osmo-pcap/files/0001-Rename-osmo_pcap_-client_server-executables-to-osmo-.patch
@@ -0,0 +1,32 @@
+From 29cbf9b031fc425032c9acf2dce2095c2cc67bf4 Mon Sep 17 00:00:00 2001
+From: Harald Welte <laforge at gnumonks.org>
+Date: Fri, 21 Jul 2017 11:45:38 +0200
+Subject: [PATCH] Rename osmo_pcap_{client_server} executables to
+ osmo-pcap-{client,server}
+
+This naming is more in line with what all the other osmocom programs are
+doing (e.g. osmo-pcu, osmo-bts-sysmo, osmo-bsc, ...).  We don't
+generally use osmo_ anywhere else, so I suggest to change it for more
+uniformity.
+
+Change-Id: If1e3ce76f93266e0f01c801204769432b571fdb1
+---
+ src/Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 0532acf..17ed4e3 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -1,7 +1,7 @@
+ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/
+ AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(PCAP_CFLAGS) $(LIBGNUTLS_CFLAGS)
+ 
+-bin_PROGRAMS = osmo_pcap_client osmo_pcap_server
++bin_PROGRAMS = osmo-pcap-client osmo-pcap-server
+ 
+ osmo_pcap_client_SOURCES = osmo_client_main.c osmo_common.c \
+ 			   osmo_client_core.c osmo_client_vty.c \
+-- 
+2.13.3
+
diff --git a/recipes-osmocom/osmo-pcap/files/0001-sock_src_init-Don-t-freeaddrinfo-undefined-src_resul.patch b/recipes-osmocom/osmo-pcap/files/0001-sock_src_init-Don-t-freeaddrinfo-undefined-src_resul.patch
new file mode 100644
index 0000000..d612cbe
--- /dev/null
+++ b/recipes-osmocom/osmo-pcap/files/0001-sock_src_init-Don-t-freeaddrinfo-undefined-src_resul.patch
@@ -0,0 +1,32 @@
+From 2c679da8a6fba49511a453f21e2311d9d0e281d0 Mon Sep 17 00:00:00 2001
+From: Harald Welte <laforge at gnumonks.org>
+Date: Fri, 21 Jul 2017 13:06:15 +0200
+Subject: [PATCH] sock_src_init(): Don't freeaddrinfo() undefined src_result
+
+src_result is only valid "if (src)", so we cannot unconditionally
+free it:
+
+(gdb) bt
+    host=0x52 <error: Cannot access memory at address 0x52>, src=0x0)
+    at /usr/src/debug/osmo-pcap/0.0.6+gitrAUTOINC+4776b2972e-r1d/git/src/osmo_client_network.c:165
+---
+ src/osmo_client_network.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c
+index 937caa0..27c649a 100644
+--- a/src/osmo_client_network.c
++++ b/src/osmo_client_network.c
+@@ -162,7 +162,8 @@ static int sock_src_init(uint16_t family, uint16_t type, uint8_t proto,
+ 		close(sfd);
+ 	}
+ 	freeaddrinfo(result);
+-	freeaddrinfo(src_result);
++	if (src)
++		freeaddrinfo(src_result);
+ 
+ 	if (rp == NULL) {
+ 		fprintf(stderr, "unable to connect/bind socket: %s:%u: %s\n",
+-- 
+2.11.0
+
diff --git a/recipes-osmocom/osmo-pcap/files/0002-Use-TCP-port-numbers-for-VTY-that-don-t-overlap-with.patch b/recipes-osmocom/osmo-pcap/files/0002-Use-TCP-port-numbers-for-VTY-that-don-t-overlap-with.patch
new file mode 100644
index 0000000..8ab2c19
--- /dev/null
+++ b/recipes-osmocom/osmo-pcap/files/0002-Use-TCP-port-numbers-for-VTY-that-don-t-overlap-with.patch
@@ -0,0 +1,84 @@
+From 285808ea15ff4e81abd3114101e10b800e120be2 Mon Sep 17 00:00:00 2001
+From: Harald Welte <laforge at gnumonks.org>
+Date: Fri, 21 Jul 2017 11:55:04 +0200
+Subject: [PATCH] Use TCP port numbers for VTY that don't overlap with other
+ Osmocom Software
+
+osmo-pcap historically was using port numbers that ware already used by
+OsmoPCU and OsmoBTS.  This leads to problems when wanting to run related
+software together on one system.  Let's break the historical assumptions
+and start with non-overlapping port numbers that are allocated/assigned
+from https://osmocom.org/projects/cellular-infrastructure/wiki/Port_Numbers
+
+Change-Id: I638ac0534517931d0987ce9f72f5db4f5b6c16b7
+---
+ include/osmo-pcap/common.h | 9 +++++++++
+ osmoappdesc.py             | 4 ++--
+ src/osmo_client_main.c     | 2 +-
+ src/osmo_server_main.c     | 2 +-
+ 4 files changed, 13 insertions(+), 4 deletions(-)
+
+diff --git a/include/osmo-pcap/common.h b/include/osmo-pcap/common.h
+index 13c76e1..27fd514 100644
+--- a/include/osmo-pcap/common.h
++++ b/include/osmo-pcap/common.h
+@@ -28,6 +28,15 @@
+ #include <osmocom/vty/vty.h>
+ #include <osmocom/vty/buffer.h>
+ #include <osmocom/vty/command.h>
++#include <osmocom/vty/ports.h>
++
++/* support old versions of libosmocore */
++#ifndef OSMO_VTY_PORT_PCAP_CLIENT
++#define OSMO_VTY_PORT_PCAP_CLIENT	4237
++#endif
++#ifndef OSMO_VTY_PORT_PCAP_SERVER
++#define OSMO_VTY_PORT_PCAP_SERVER	4238
++#endif
+ 
+ enum {
+ 	DPCAP,
+diff --git a/osmoappdesc.py b/osmoappdesc.py
+index 39928eb..6f66702 100644
+--- a/osmoappdesc.py
++++ b/osmoappdesc.py
+@@ -20,8 +20,8 @@ app_configs = {
+ }
+ 
+ apps = [
+-    (4241, "src/osmo_pcap_server", "OsmoPCAPServer", "osmo-pcap-server"),
+-    (4240, "src/osmo_pcap_client", "OsmoPCAPClient", "osmo-pcap-client"),
++    (4238, "src/osmo_pcap_server", "OsmoPCAPServer", "osmo-pcap-server"),
++    (4237, "src/osmo_pcap_client", "OsmoPCAPClient", "osmo-pcap-client"),
+         ]
+ 
+ vty_command = ["src/osmo_pcap_server", "-c", "contrib/osmo-pcap-server.cfg"]
+diff --git a/src/osmo_client_main.c b/src/osmo_client_main.c
+index 89d7e04..46a49b5 100644
+--- a/src/osmo_client_main.c
++++ b/src/osmo_client_main.c
+@@ -206,7 +206,7 @@ int main(int argc, char **argv)
+ 
+ 	osmo_tls_init();
+ 
+-	rc = telnet_init(tall_bsc_ctx, NULL, 4240);
++	rc = telnet_init(tall_bsc_ctx, NULL, OSMO_VTY_PORT_PCAP_CLIENT);
+ 	if (rc < 0) {
+ 		LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n");
+ 		exit(1);
+diff --git a/src/osmo_server_main.c b/src/osmo_server_main.c
+index 37a9632..95f3ce1 100644
+--- a/src/osmo_server_main.c
++++ b/src/osmo_server_main.c
+@@ -219,7 +219,7 @@ int main(int argc, char **argv)
+ 
+ 	osmo_tls_init();
+ 
+-	rc = telnet_init(tall_bsc_ctx, NULL, 4241);
++	rc = telnet_init(tall_bsc_ctx, NULL, OSMO_VTY_PORT_PCAP_SERVER);
+ 	if (rc < 0) {
+ 		LOGP(DCLIENT, LOGL_ERROR, "Failed to bind telnet interface\n");
+ 		exit(1);
+-- 
+2.13.3
+
diff --git a/recipes-osmocom/osmo-pcap/files/osmo-pcap-client.service b/recipes-osmocom/osmo-pcap/files/osmo-pcap-client.service
new file mode 100644
index 0000000..43e6c62
--- /dev/null
+++ b/recipes-osmocom/osmo-pcap/files/osmo-pcap-client.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Osmocom PCAP aggregation client (probe)
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/osmo-pcap-client -c /etc/osmocom/osmo-pcap-client.cfg
+Restart=always
+RestartSec=2
+RestartPreventExitStatus=1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/recipes-osmocom/osmo-pcap/files/osmo-pcap-server.service b/recipes-osmocom/osmo-pcap/files/osmo-pcap-server.service
new file mode 100644
index 0000000..fcadeb2
--- /dev/null
+++ b/recipes-osmocom/osmo-pcap/files/osmo-pcap-server.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Osmocom PCAP aggregation server
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/osmo-pcap-server -c /etc/osmocom/osmo-pcap-server.cfg
+Restart=always
+RestartSec=2
+RestartPreventExitStatus=1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/recipes-osmocom/osmo-pcap/osmo-pcap_git.bb b/recipes-osmocom/osmo-pcap/osmo-pcap_git.bb
new file mode 100644
index 0000000..f004de2
--- /dev/null
+++ b/recipes-osmocom/osmo-pcap/osmo-pcap_git.bb
@@ -0,0 +1,55 @@
+DESCRITOPN = "Osmocom PCAP clint (probe) and server (aggregator)"
+LICENSE = "AGPLv3+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=73f1eb20517c55bf9493b7dd6e480788"
+PV = "0.0.6+gitr${SRCPV}"
+PR = "r1h"
+
+SRCREV = "${AUTOREV}"
+SRC_URI = "git://git.osmocom.org/osmo-pcap                  \
+	   file://0001-Rename-osmo_pcap_-client_server-executables-to-osmo-.patch \
+	   file://0002-Use-TCP-port-numbers-for-VTY-that-don-t-overlap-with.patch \
+	   file://0001-sock_src_init-Don-t-freeaddrinfo-undefined-src_resul.patch \
+	   file://osmo-pcap-client.service \
+	   file://osmo-pcap-server.service \
+          "
+S = "${WORKDIR}/git"
+
+DEPENDS = "libosmocore zeromq libpcap gnutls"
+
+PACKAGES =+ "osmo-pcap-server osmo-pcap-client"
+
+inherit autotools pkgconfig systemd
+
+SYSTEMD_PACKAGES = "osmo-pcap-server osmo-pcap-client"
+
+EXTRA_OECONF += "--with-pcap-config=no"
+
+do_configure_prepend() {
+	export PCAP_LIBS="-lpcap"
+}
+
+do_install_append() {
+	install -d ${D}${systemd_unitdir}/system
+	install -m 0644 ${WORKDIR}/osmo-pcap-client.service ${D}${systemd_unitdir}/system/
+	install -m 0644 ${WORKDIR}/osmo-pcap-server.service ${D}${systemd_unitdir}/system/
+
+	install -d ${D}${sysconfdir}/osmocom
+	install -m 0660 ${S}/contrib/osmo-pcap-client.cfg ${D}${sysconfdir}/osmocom/
+	install -m 0660 ${S}/contrib/osmo-pcap-server.cfg ${D}${sysconfdir}/osmocom/
+
+	install -d ${D}${sysconfdir}/cron.daily
+	mv ${D}${datadir}/osmo-pcap/osmo_pcap_clean_old ${D}${sysconfdir}/cron.daily/
+	rmdir ${D}${datadir}/osmo-pcap
+	rmdir ${D}${datadir}
+}
+
+
+FILES_osmo-pcap-server = "${bindir}/osmo-pcap-server \
+			  ${systemd_unitdir}/system/osmo-pcap-server.service \
+			  ${sysconfdir}/osmocom/osmo-pcap-server.cfg \
+			  ${sysconfdir}/cron.daily/osmo_pcap_clean_old"
+
+FILES_osmo-pcap-client = "${bindir}/osmo-pcap-client \
+			  ${systemd_unitdir}/system/osmo-pcap-client.service \
+			  ${sysconfdir}/osmocom/osmo-pcap-client.cfg \
+			  ${sysconfdir}/cron.d/cron.daily/osmo_pcap_clean_old"

-- 
To view, visit https://gerrit.osmocom.org/3534
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5bb85b118029d1559a958803184690a9d0f23e4a
Gerrit-PatchSet: 1
Gerrit-Project: meta-telephony
Gerrit-Branch: 201705
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list