From patchwork Sun May 4 09:06:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Eversberg X-Patchwork-Id: 345452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [213.95.27.120]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3E9B0140185 for ; Sun, 4 May 2014 19:08:39 +1000 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WgsPH-0005LJ-Ck; Sun, 04 May 2014 11:08:23 +0200 Received: from mx.ibsd.net ([62.214.121.40]) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WgsNn-0005L3-76 for openbsc@lists.osmocom.org; Sun, 04 May 2014 11:06:55 +0200 Received: from mx0.ibsd.net ([62.214.121.44]) by mx-3.ibsd.net with ESMTP; 04 May 2014 11:06:50 +0200 Received: from mail.ibsd.net (mail.ibsd.net [62.214.121.35]) by mx0.ibsd.net (8.13.8/8.13.8) with ESMTP id s4496o4F030725; Sun, 4 May 2014 11:06:50 +0200 Received: from [10.0.0.32] (home.eversberg.eu [82.139.198.227]) (authenticated bits=0) by mail.ibsd.net (8.13.8/8.13.8) with ESMTP id s4496lC8026388; Sun, 4 May 2014 11:06:47 +0200 Message-ID: <53660327.5000705@eversberg.eu> Date: Sun, 04 May 2014 11:06:47 +0200 From: Andreas Eversberg User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24 MIME-Version: 1.0 To: Holger Hans Peter Freyther Subject: Re: [PATCH 6/9] Add traffic forwarding via RTP to remote application References: <1392793078-30854-6-git-send-email-jolly@eversberg.eu> <20140309161952.GC6167@xiaoyu.lan> <531EAD2D.6000702@eversberg.eu> <20140314064042.GJ31238@xiaoyu.lan> <53242052.1070401@eversberg.eu> <20140316071240.GD27189@xiaoyu.lan> <53269940.7050101@eversberg.eu> <20140320214938.GB11963@xiaoyu.lan> <20140417212908.GA31314@xiaoyu.lan> <5350FCE7.9030401@eversberg.eu> <20140420143357.GE14607@xiaoyu.lan> In-Reply-To: <20140420143357.GE14607@xiaoyu.lan> X-Spam-Score: 0.0 (/) Cc: openbsc@lists.osmocom.org, laforge@gnumonks.org X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org >> S_LCHAN_HANDOVER_FAIL, /* 04.08 Handover Failed */ >> S_LCHAN_HANDOVER_DETECT, /* 08.58 Handover Detect */ >> S_LCHAN_MEAS_REP, /* 08.58 Measurement Report */ >> + S_LCHAN_RTP_SOCKET_FREE, > Use the opportunity to write a bit of information here? Or maybe > just use S_CHALLOC_FREED to free rtp_socket and introduce a > S_CHALLOC_RESET to do it in the later case? > >> + struct lchan_signal_data sig; dear holger, i chose to use S_CHALLOC_* to trigger RTP socket freeing. see attached patch. best regards andreas From 7b20bbc32146c1a8b5e0191d838b45735f1ae151 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Fri, 18 Apr 2014 11:03:50 +0200 Subject: [PATCH] Move rtp_proxy.c from libtrau to libmsc In order to free RTP socket when lchan_free() or lchan_reset() is called, a signal is used between libbsc and rtp_proxy. --- openbsc/include/openbsc/signal.h | 1 + openbsc/src/libbsc/chan_alloc.c | 19 +++++++--------- openbsc/src/libmsc/Makefile.am | 3 ++- openbsc/src/{libtrau => libmsc}/rtp_proxy.c | 35 +++++++++++++++++++++++++++++ openbsc/src/libtrau/Makefile.am | 2 +- 5 files changed, 47 insertions(+), 13 deletions(-) rename openbsc/src/{libtrau => libmsc}/rtp_proxy.c (96%) diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h index 39319f1..31c9187 100644 --- a/openbsc/include/openbsc/signal.h +++ b/openbsc/include/openbsc/signal.h @@ -105,6 +105,7 @@ enum signal_lchan { enum signal_challoc { S_CHALLOC_ALLOC_FAIL, /* allocation of lchan has failed */ S_CHALLOC_FREED, /* lchan has been successfully freed */ + S_CHALLOC_RESET, /* lchan has been reset */ }; /* SS_SUBSCR signals */ diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c index 9b74329..18ffa93 100644 --- a/openbsc/src/libbsc/chan_alloc.c +++ b/openbsc/src/libbsc/chan_alloc.c @@ -310,13 +310,6 @@ void lchan_free(struct gsm_lchan *lchan) osmo_signal_dispatch(SS_LCHAN, S_LCHAN_UNEXPECTED_RELEASE, &sig); } - if (lchan->abis_ip.rtp_socket) { - LOGP(DRLL, LOGL_ERROR, "%s RTP Proxy Socket remained open.\n", - gsm_lchan_name(lchan)); - rtp_socket_free(lchan->abis_ip.rtp_socket); - lchan->abis_ip.rtp_socket = NULL; - } - /* stop the timer */ osmo_timer_del(&lchan->T3101); @@ -360,18 +353,22 @@ void lchan_free(struct gsm_lchan *lchan) */ void lchan_reset(struct gsm_lchan *lchan) { + struct challoc_signal_data sig; + osmo_timer_del(&lchan->T3101); osmo_timer_del(&lchan->T3109); osmo_timer_del(&lchan->T3111); osmo_timer_del(&lchan->error_timer); + memset(&sig, 0, sizeof(sig)); + sig.type = lchan->type; + lchan->type = GSM_LCHAN_NONE; lchan->state = LCHAN_S_NONE; - if (lchan->abis_ip.rtp_socket) { - rtp_socket_free(lchan->abis_ip.rtp_socket); - lchan->abis_ip.rtp_socket = NULL; - } + sig.lchan = lchan; + sig.bts = lchan->ts->trx->bts; + osmo_signal_dispatch(SS_CHALLOC, S_CHALLOC_RESET, &sig); } /* Drive the release process of the lchan */ diff --git a/openbsc/src/libmsc/Makefile.am b/openbsc/src/libmsc/Makefile.am index 24db2c2..4d44a62 100644 --- a/openbsc/src/libmsc/Makefile.am +++ b/openbsc/src/libmsc/Makefile.am @@ -17,7 +17,8 @@ libmsc_a_SOURCES = auth.c \ ussd.c \ vty_interface_layer3.c \ transaction.c \ - osmo_msc.c ctrl_commands.c + osmo_msc.c ctrl_commands.c \ + rtp_proxy.c if BUILD_SMPP noinst_HEADERS = smpp_smsc.h diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libmsc/rtp_proxy.c similarity index 96% rename from openbsc/src/libtrau/rtp_proxy.c rename to openbsc/src/libmsc/rtp_proxy.c index 82d50ae..b86d228 100644 --- a/openbsc/src/libtrau/rtp_proxy.c +++ b/openbsc/src/libmsc/rtp_proxy.c @@ -36,6 +36,7 @@ #include #include #include +#include /* attempt to determine byte order */ #include @@ -830,3 +831,37 @@ int rtp_socket_free(struct rtp_socket *rs) return 0; } + +static int rtp_handle_challoc_signal(unsigned int subsys, unsigned int signal, + void *handler_data, void *signal_data) +{ + struct gsm_lchan *lchan; + struct challoc_signal_data *sig; + + if (subsys != SS_CHALLOC) + return 0; + + + sig = signal_data; + if (!sig->lchan || !sig->lchan->conn) + return 0; + + lchan = sig->lchan; + + switch (signal) { + case S_CHALLOC_FREED: + case S_CHALLOC_RESET: + if (lchan->abis_ip.rtp_socket) { + rtp_socket_free(lchan->abis_ip.rtp_socket); + lchan->abis_ip.rtp_socket = NULL; + } + break; + } + + return 0; +} + +static __attribute__((constructor)) void on_dso_load_rtp_proxy(void) +{ + osmo_signal_register_handler(SS_CHALLOC, rtp_handle_challoc_signal, NULL); +} diff --git a/openbsc/src/libtrau/Makefile.am b/openbsc/src/libtrau/Makefile.am index 0c8cf17..7b71417 100644 --- a/openbsc/src/libtrau/Makefile.am +++ b/openbsc/src/libtrau/Makefile.am @@ -4,4 +4,4 @@ AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) $(COVERA noinst_LIBRARIES = libtrau.a -libtrau_a_SOURCES = rtp_proxy.c trau_mux.c trau_upqueue.c +libtrau_a_SOURCES = trau_mux.c trau_upqueue.c -- 1.8.1.5