pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-netif/+/38841?usp=email )
Change subject: Drop libosmo-abis cond dep together with examples/lapd-over-datagram
......................................................................
Drop libosmo-abis cond dep together with examples/lapd-over-datagram
libosmo-netif should never depend on libosmo-abis, since it provides
interfaces way more generic than libosmo-abis.
libosmo-abis will in the near future use libosmo-netif's stream APIs, so
break the circular dependency here.
The lapd-over-datagram-* examples will be moved to libosmo-abis since
lapd stuff is defined there.
Change-Id: I13d6e88158f6d9ce017986283183ee9c2cc68cae
---
M configure.ac
M contrib/jenkins.sh
M examples/Makefile.am
D examples/lapd-over-datagram-network.c
D examples/lapd-over-datagram-user.c
M src/Makefile.am
6 files changed, 2 insertions(+), 447 deletions(-)
Approvals:
pespin: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
diff --git a/configure.ac b/configure.ac
index 98755cf..9513270 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,19 +93,6 @@
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.10.0)
PKG_CHECK_MODULES(LIBOSMOCODEC, libosmocodec >= 1.10.0)
-AC_ARG_ENABLE([lapd_examples],
- [AS_HELP_STRING(
- [--enable-lapd-examples],
- [Build some lapd examples]
- )],
- [lapd_examples=$enableval], [lapd_examples="no"])
-AS_IF([test "x$lapd_examples" = "xyes"], [
- PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 1.5.0)
- AC_DEFINE([ENABLE_LAPD], [1], [Enable LAPD examples])
-])
-AM_CONDITIONAL(ENABLE_LAPD, test "x$lapd_examples" = "xyes")
-AC_SUBST(ENABLE_LAPD)
-
AC_ARG_ENABLE([libsctp], [AS_HELP_STRING([--disable-libsctp], [Do not enable socket
multiaddr APIs requiring libsctp])],
[ENABLE_LIBSCTP=$enableval], [ENABLE_LIBSCTP="yes"])
AM_CONDITIONAL(ENABLE_LIBSCTP, test x"$ENABLE_LIBSCTP" = x"yes")
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 543671c..53af2e0 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -24,7 +24,6 @@
export LD_LIBRARY_PATH="$inst/lib"
osmo-build-dep.sh libosmocore "" --disable-doxygen
-osmo-build-dep.sh libosmo-abis
set +x
echo
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 6d74238..6c9cd6a 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,5 +1,5 @@
AM_CPPFLAGS = -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -g $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS)
$(COVERAGE_CFLAGS)
+AM_CFLAGS=-Wall -g $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(COVERAGE_CFLAGS)
AM_LDFLAGS = $(COVERAGE_LDFLAGS)
noinst_PROGRAMS = ipa-stream-client \
@@ -25,19 +25,6 @@
ipa_stream_server_LDADD = $(top_builddir)/src/libosmonetif.la \
$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
-if ENABLE_LAPD
-noinst_PROGRAMS += lapd-over-datagram-user lapd-over-datagram-network
-lapd_over_datagram_user_SOURCES = lapd-over-datagram-user.c
-lapd_over_datagram_user_LDADD = $(top_builddir)/src/libosmonetif.la \
- $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) \
- $(LIBOSMOABIS_LIBS)
-
-lapd_over_datagram_network_SOURCES = lapd-over-datagram-network.c
-lapd_over_datagram_network_LDADD = $(top_builddir)/src/libosmonetif.la \
- $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) \
- $(LIBOSMOABIS_LIBS)
-endif
-
stream_client_SOURCES = stream-client.c
stream_client_LDADD = $(top_builddir)/src/libosmonetif.la \
$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
diff --git a/examples/lapd-over-datagram-network.c
b/examples/lapd-over-datagram-network.c
deleted file mode 100644
index 58ba0ce..0000000
--- a/examples/lapd-over-datagram-network.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* LAPD over datagram network-mode example. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/logging.h>
-#include <osmocom/core/application.h>
-#include <osmocom/core/select.h>
-
-#include <osmocom/abis/lapd.h>
-
-#include <osmocom/netif/datagram.h>
-
-static void *tall_test;
-
-#define DLAPDTEST 0
-
-struct log_info_cat lapd_test_cat[] = {
- [DLAPDTEST] = {
- .name = "DLAPDTEST",
- .description = "LAPD-mode test",
- .color = "\033[1;35m",
- .enabled = 1, .loglevel = LOGL_DEBUG,
- },
-};
-
-const struct log_info lapd_test_log_info = {
- .filter_fn = NULL,
- .cat = lapd_test_cat,
- .num_cat = ARRAY_SIZE(lapd_test_cat),
-};
-
-static struct osmo_dgram *conn;
-static struct lapd_instance *lapd;
-static int tei = 0;
-
-void sighandler(int foo)
-{
- lapd_instance_free(lapd);
- LOGP(DLAPDTEST, LOGL_NOTICE, "closing LAPD.\n");
- exit(EXIT_SUCCESS);
-}
-
-int read_cb(struct osmo_dgram *conn)
-{
- int error;
- struct msgb *msg;
-
- LOGP(DLAPDTEST, LOGL_DEBUG, "received message from datagram\n");
-
- msg = msgb_alloc(1200, "LAPD/test");
- if (msg == NULL) {
- LOGP(DLAPDTEST, LOGL_ERROR, "cannot allocate message\n");
- return -1;
- }
- if (osmo_dgram_recv(conn, msg) < 0) {
- LOGP(DLAPDTEST, LOGL_ERROR, "cannot receive message\n");
- return -1;
- }
- if (lapd_receive(lapd, msg, &error) < 0) {
- LOGP(DLAPDTEST, LOGL_ERROR, "lapd_receive returned error!\n");
- return -1;
- }
-
- return 0;
-}
-
-void lapd_tx_cb(struct msgb *msg, void *cbdata)
-{
- struct osmo_dgram *conn = cbdata;
-
- LOGP(DLAPDTEST, LOGL_DEBUG, "sending message over datagram\n");
- osmo_dgram_send(conn, msg);
-}
-
-void lapd_rx_cb(struct osmo_dlsap_prim *dp, uint8_t tei, uint8_t sapi,
- void *rx_cbdata)
-{
- struct msgb *msg = dp->oph.msg;
-
- switch (dp->oph.primitive) {
- case PRIM_DL_EST:
- DEBUGP(DLAPDTEST, "DL_EST: sapi(%d) tei(%d)\n", sapi, tei);
- break;
- case PRIM_DL_REL:
- DEBUGP(DLAPDTEST, "DL_REL: sapi(%d) tei(%d)\n", sapi, tei);
- break;
- case PRIM_DL_DATA:
- case PRIM_DL_UNIT_DATA:
- if (dp->oph.operation == PRIM_OP_INDICATION) {
- struct msgb *nmsg;
- char *ptr;
- int x;
-
- msg->l2h = msg->l3h;
-
- DEBUGP(DLAPDTEST, "RX: %s sapi=%d tei=%d\n",
- osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)),
- sapi, tei);
-
- LOGP(DLAPDTEST, LOGL_DEBUG, "forwarding message\n");
-
- nmsg = msgb_alloc(1024, "LAPD/test");
- if (nmsg == NULL) {
- LOGP(DLAPDTEST, LOGL_ERROR, "cannot alloc
msg\n");
- return;
- }
- ptr = (char *)msgb_put(nmsg, sizeof(int));
-
- x = *((int *)msg->data);
- memcpy(ptr, &x, sizeof(int));
-
- /* send the message back to client over LAPD */
- lapd_transmit(lapd, tei, sapi, msg);
- return;
- }
- break;
- case PRIM_MDL_ERROR:
- DEBUGP(DLMI, "MDL_EERROR: cause(%d)\n", dp->u.error_ind.cause);
- break;
- default:
- printf("ERROR: unknown prim\n");
- break;
- }
-}
-
-int main(int argc, char *argv[])
-{
- struct lapd_tei *teip;
-
- tall_test = talloc_named_const(NULL, 1, "lapd_test");
- msgb_talloc_ctx_init(tall_test, 0);
- osmo_init_logging2(tall_test, &lapd_test_log_info);
- log_set_log_level(osmo_stderr_target, LOGL_NOTICE);
-
- /*
- * initialize datagram server.
- */
-
- conn = osmo_dgram_create(tall_test);
- if (conn == NULL) {
- fprintf(stderr, "cannot create client\n");
- exit(EXIT_FAILURE);
- }
- osmo_dgram_set_local_addr(conn, "127.0.0.1");
- osmo_dgram_set_local_port(conn, 10001);
- osmo_dgram_set_remote_addr(conn, "127.0.0.1");
- osmo_dgram_set_remote_port(conn, 10000);
- osmo_dgram_set_read_cb(conn, read_cb);
-
- lapd = lapd_instance_alloc(1, lapd_tx_cb, conn, lapd_rx_cb, conn,
- &lapd_profile_sat);
- if (lapd == NULL) {
- LOGP(DLAPDTEST, LOGL_ERROR, "cannot allocate instance\n");
- exit(EXIT_FAILURE);
- }
-
- teip = lapd_tei_alloc(lapd, tei);
- if (teip == NULL) {
- LOGP(DLAPDTEST, LOGL_ERROR, "cannot assign TEI\n");
- exit(EXIT_FAILURE);
- }
-
- if (osmo_dgram_open(conn) < 0) {
- fprintf(stderr, "cannot open client\n");
- exit(EXIT_FAILURE);
- }
-
- LOGP(DLAPDTEST, LOGL_NOTICE, "Entering main loop\n");
-
- while(1) {
- osmo_select_main(0);
- }
-}
diff --git a/examples/lapd-over-datagram-user.c b/examples/lapd-over-datagram-user.c
deleted file mode 100644
index f11f49f..0000000
--- a/examples/lapd-over-datagram-user.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/* LAPD over datagram user-mode example. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-
-#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/logging.h>
-#include <osmocom/core/application.h>
-#include <osmocom/core/select.h>
-
-#include <osmocom/abis/lapd.h>
-
-#include <osmocom/netif/datagram.h>
-
-static LLIST_HEAD(msg_sent_list);
-
-struct msg_sent {
- struct llist_head head;
- struct msgb *msg;
- int num;
- struct timeval tv;
-};
-
-#define DLAPDTEST 0
-
-struct log_info_cat lapd_test_cat[] = {
- [DLAPDTEST] = {
- .name = "DLAPDTEST",
- .description = "LAPD-mode test",
- .color = "\033[1;35m",
- .enabled = 1, .loglevel = LOGL_DEBUG,
- },
-};
-
-const struct log_info lapd_test_log_info = {
- .filter_fn = NULL,
- .cat = lapd_test_cat,
- .num_cat = ARRAY_SIZE(lapd_test_cat),
-};
-
-static struct osmo_dgram *conn;
-static struct lapd_instance *lapd;
-static int sapi = 63, tei = 0;
-
-void sighandler(int foo)
-{
- lapd_sap_stop(lapd, tei, sapi);
- lapd_instance_free(lapd);
- LOGP(DLINP, LOGL_NOTICE, "closing LAPD.\n");
- exit(EXIT_SUCCESS);
-}
-
-static int read_cb(struct osmo_dgram *conn)
-{
- int error;
- struct msgb *msg;
-
- msg = msgb_alloc(1200, "LAPD/test");
- if (msg == NULL) {
- LOGP(DLAPDTEST, LOGL_ERROR, "cannot allocate message\n");
- return -1;
- }
- if (osmo_dgram_recv(conn, msg) < 0) {
- msgb_free(msg);
- LOGP(DLAPDTEST, LOGL_ERROR, "cannot receive message\n");
- return -1;
- }
- if (lapd_receive(lapd, msg, &error) < 0) {
- msgb_free(msg);
- LOGP(DLINP, LOGL_ERROR, "lapd_receive returned error!\n");
- return -1;
- }
- return 0;
-}
-
-static void *tall_test;
-
-void lapd_tx_cb(struct msgb *msg, void *cbdata)
-{
- LOGP(DLINP, LOGL_DEBUG, "sending message over datagram\n");
- osmo_dgram_send(conn, msg);
-}
-
-void lapd_rx_cb(struct osmo_dlsap_prim *dp, uint8_t tei, uint8_t sapi,
- void *rx_cbdata)
-{
- struct msgb *msg = dp->oph.msg;
- int *__msgs = rx_cbdata;
- int num_msgs = *__msgs;
-
- switch (dp->oph.primitive) {
- case PRIM_DL_EST:
- DEBUGP(DLAPDTEST, "DL_EST: sapi(%d) tei(%d)\n", sapi, tei);
-
- int i;
- for (i=0; i<num_msgs; i++) {
- struct msgb *msg;
- struct msg_sent *msg_sent;
- char *ptr;
- int x;
-
- msg = msgb_alloc(1024, "LAPD/test");
- if (msg == NULL) {
- LOGP(DLINP, LOGL_ERROR, "cannot alloc msg\n");
- return;
- }
- ptr = (char *)msgb_put(msg, sizeof(int));
-
- x = htonl(i);
- memcpy(ptr, &x, sizeof(int));
-
- msg_sent = talloc_zero(NULL, struct msg_sent);
- if (msg_sent == NULL) {
- LOGP(DLINP, LOGL_ERROR, "can't alloc struct\n");
- return;
- }
- msg_sent->msg = msg;
- gettimeofday(&msg_sent->tv, NULL);
- msg_sent->num = i;
- llist_add(&msg_sent->head, &msg_sent_list);
-
- lapd_transmit(lapd, tei, sapi, msg);
-
- LOGP(DLAPDTEST, LOGL_DEBUG, "enqueueing msg %d of "
- "%d bytes to be sent over LAPD\n", i, msg->len);
- }
- break;
- case PRIM_DL_REL:
- DEBUGP(DLAPDTEST, "DL_REL: sapi(%d) tei(%d)\n", sapi, tei);
- break;
- case PRIM_DL_DATA:
- case PRIM_DL_UNIT_DATA:
- if (dp->oph.operation == PRIM_OP_INDICATION) {
- msg->l2h = msg->l3h;
- DEBUGP(DLAPDTEST, "RX: %s sapi=%d tei=%d\n",
- osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)),
- sapi, tei);
-
- int num;
- struct msg_sent *cur, *tmp, *found = NULL;
-
- num = ntohl(*((int *)msg->data));
- LOGP(DLINP, LOGL_DEBUG,
- "received msg number %d\n", num);
-
- llist_for_each_entry_safe(cur, tmp,
- &msg_sent_list, head) {
- if (cur->num == num) {
- llist_del(&cur->head);
- found = cur;
- break;
- }
- }
- if (found) {
- struct timeval tv, diff;
-
- gettimeofday(&tv, NULL);
- timersub(&tv, &found->tv, &diff);
-
- LOGP(DLINP, LOGL_NOTICE, "message %d replied "
- "in %lu.%.6lu\n",
- num, diff.tv_sec, diff.tv_usec);
- talloc_free(found);
- } else {
- LOGP(DLINP, LOGL_ERROR,
- "message %d not found!\n", num);
- }
- }
- break;
- case PRIM_MDL_ERROR:
- DEBUGP(DLMI, "MDL_EERROR: cause(%d)\n", dp->u.error_ind.cause);
- break;
- default:
- printf("ERROR: unknown prim\n");
- break;
- }
-}
-
-int main(int argc, char *argv[])
-{
- int num_msgs;
-
- signal(SIGINT, sighandler);
-
- if (argc != 2) {
- printf("Usage: %s [num_msgs]\n", argv[0]);
- exit(EXIT_FAILURE);
- }
- num_msgs = atoi(argv[1]);
-
- tall_test = talloc_named_const(NULL, 1, "lapd_test");
- msgb_talloc_ctx_init(tall_test, 0);
- osmo_init_logging2(tall_test, &lapd_test_log_info);
- log_set_log_level(osmo_stderr_target, LOGL_NOTICE);
- /*
- * initialize LAPD stuff.
- */
-
- lapd = lapd_instance_alloc(0, lapd_tx_cb, NULL, lapd_rx_cb, &num_msgs,
- &lapd_profile_sat);
- if (lapd == NULL) {
- LOGP(DLINP, LOGL_ERROR, "cannot allocate instance\n");
- exit(EXIT_FAILURE);
- }
-
- /*
- * initialize datagram socket.
- */
-
- conn = osmo_dgram_create(tall_test);
- if (conn == NULL) {
- fprintf(stderr, "cannot create client\n");
- exit(EXIT_FAILURE);
- }
- osmo_dgram_set_local_addr(conn, "127.0.0.1");
- osmo_dgram_set_local_port(conn, 10000);
- osmo_dgram_set_remote_addr(conn, "127.0.0.1");
- osmo_dgram_set_remote_port(conn, 10001);
- osmo_dgram_set_read_cb(conn, read_cb);
-
- if (osmo_dgram_open(conn) < 0) {
- fprintf(stderr, "cannot open client\n");
- exit(EXIT_FAILURE);
- }
-
- if (lapd_sap_start(lapd, tei, sapi) < 0) {
- LOGP(DLINP, LOGL_ERROR, "cannot start user-side LAPD\n");
- exit(EXIT_FAILURE);
- }
-
- LOGP(DLINP, LOGL_NOTICE, "Entering main loop\n");
-
- while(1) {
- osmo_select_main(0);
- }
-}
diff --git a/src/Makefile.am b/src/Makefile.am
index 2ceadc0..258d04a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,7 @@
LIBVERSION=13:1:2
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS= -fPIC -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS)
$(COVERAGE_CFLAGS) $(LIBSCTP_CFLAGS)
+AM_CFLAGS= -fPIC -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(COVERAGE_CFLAGS)
$(LIBSCTP_CFLAGS)
AM_LDFLAGS = $(COVERAGE_LDFLAGS)
lib_LTLIBRARIES = libosmonetif.la
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-netif/+/38841?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I13d6e88158f6d9ce017986283183ee9c2cc68cae
Gerrit-Change-Number: 38841
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>